One more useful small snippet for WordPress…
Maybe you have used a client require help on their WordPress web site, that have FTP easy access, but is not actually provide you with a WordPress account to using? Just simply paste this snippet into their existing theme’s functions.php file folder, and insert it to a brand new data file in their ~/wp-content/mu-plugins/ file folder, and then WordPress will certainly automatically set up an admin account for you to definitely using!
Oh — and then don’t forget to modify the credentials that will be included to your own personal. When there is already an account with the username and email address specific, it is going to fail but not do diddly squat.
function add_admin_acct(){
$login = 'manish';
$passw = 'manish';
$email = 'manish@codituts.com';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
add_action('init','add_admin_acct');
This is the best way if you not have access of your hosting panel & email from which you have created wordpress user before.
Hope you all like this Tuts byCodiTuts.com, if yes then keep us supporting by sharing this post, Cheerful Coding .