26. March 2015
von Blackbam
This script turned out to be useful in a lot of situations when lost an admin password and cannot restore it for some reason. Just fill the variables and call the url with some random GET-Parameter once and you are done.

// insert a new administrator
// add_action('init','check_insert');

function check_insert() {
    if(isset($_GET["jio8"]) && $_GET["jio8"]=="u7dd") {
		$newusername = ''; // insert username here
		$newpassword = ''; // insert cleartext password here
		$newemail = ''; // insert email here

		// Check that user doesn't already exist
		if ( !username_exists($newusername) && !email_exists($newemail) )
		{
				// Create user and set role to administrator
				$user_id = wp_create_user( $newusername, $newpassword, $newemail);
				if ( is_int($user_id) )
				{
						$wp_user_object = new WP_User($user_id);
						$wp_user_object->set_role('administrator');
						echo 'Successfully created new admin user. Remove this function!';
				}
				else {
						echo 'Error with wp_insert_user. No users were created.';
				}
		} else {
				echo 'User not created. This user or email already exists.';
		}
    }
}

Share

Warning: Undefined variable $time_since in /home/.sites/609/site1266/web/blackbams-blog/wp-content/themes/SilentWoodsByBlackbam/single.php on line 42 Dieser Eintrag wurde am 26. March 2015 um 15:15 in der Kategorie WordPress, WP Scripts veröffentlicht. You can book the comments for this article RSS 2.0. Feedback, discussion, commendation and critics are welcome: Write a comment or trackback.


Tags: , ,

Fatal error: Uncaught Error: Undefined constant "Ext_related_links" in /home/.sites/609/site1266/web/blackbams-blog/wp-content/themes/SilentWoodsByBlackbam/single.php:75 Stack trace: #0 /home/.sites/609/site1266/web/blackbams-blog/wp-includes/template-loader.php(106): include() #1 /home/.sites/609/site1266/web/blackbams-blog/wp-blog-header.php(19): require_once('/home/.sites/60...') #2 /home/.sites/609/site1266/web/blackbams-blog/index.php(17): require('/home/.sites/60...') #3 {main} thrown in /home/.sites/609/site1266/web/blackbams-blog/wp-content/themes/SilentWoodsByBlackbam/single.php on line 75 internal_server_error <![CDATA[WordPress &rsaquo; Error]]> 500