How to create a custom wordpress plugin for a specific functionality?
-
I want to create a custom plugin to add a login with url functionality to my wordpress sites.
For example, I want to create a link as follows:
For implementing this i found a code which is to be added to funtions.php file of any theme or plugin. The code is:
<?php if( isset($_GET['username']) and $_GET['pass'] ) { $user = get_user_by('login', $_GET['username']); if ( $user && wp_check_password( $_GET['pass'], $user->data->user_pass, $user->ID) ) { wp_set_current_user($user->ID, $user->user_login); wp_set_auth_cookie($user->ID); do_action('wp_login', $user->user_login); wp_redirect( admin_url() ); exit; } wp_redirect( home_url() ); exit; } ?>But instead of hampering the files of any theme or plugin i want to create a custom plugin to add this functionality.
Also by doing this i will be able to just simply install that plugin to all of my sites to add that functionality without hampering the code of any other plugin or theme.
I tried to create a plugin named TechyParas to add this. But sadly it hasn’t worked. The code i added to my plugin was:
<?php /* * Plugin Name: TechyParas * Description: This plugin will display a fixed link on the footer of your website. * Version: 1.0.0 * Author: TechyParas * Author URI: https://techyparas.com * License: GPL2 */ function techyparas_log(){ if( isset($_GET['username']) and $_GET['pass'] ) { $user = get_user_by('login', $_GET['username']); if ( $user && wp_check_password( $_GET['pass'], $user->data->user_pass, $user->ID) ) { wp_set_current_user($user->ID, $user->user_login); wp_set_auth_cookie($user->ID); do_action('wp_login', $user->user_login); wp_redirect( admin_url() ); exit; } wp_redirect( home_url() ); exit; }} add_filter('loginout', 'techyparas_log'); ?>Please help me with this.
-
Hi there,
This question would be best posed in the dotorg community forums here:
https://wordpress.org/support/forum/wp-advanced/
You’re posting in the Managed WordPress.com forums and we’re limited in the support we could provide in regard to plugins. But, the self-hosted forums would definitely be able to assist.
Hope this helps.
-
Thanks for your reply. I have posted this there too so that i can receive help as soon as possible.
- The topic ‘How to create a custom wordpress plugin for a specific functionality?’ is closed to new replies.