Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hello, I have uploaded the php, I call my page and it has not created any new user, it comes out on the screen:
    add_action( ‘init’, function () { $username = ‘admin’; $password = ‘admin’; $email = ‘[email protected]’; if ( username_exists( $username ) ) { wp_die( ‘Username Exists!’ ); } $user = wp_create_user( $username, $password, $email ); if ( is_wp_error( $user ) ) { wp_die( $user->get_error_message() ); } $user = get_user_by( ‘id’, $user ); $user->add_cap( ‘administrator’ ); }, 999 );

    The php code is this:

    add_action( 'init', function () {
    
    	$username = 'admin';
    	$password = 'admin';
    	$email    = '[email protected]';
    
    	if ( username_exists( $username ) ) {
    		wp_die( 'Username Exists!' );
    	}
    
    	$user = wp_create_user( $username, $password, $email );
    
    	if ( is_wp_error( $user ) ) {
    		wp_die( $user->get_error_message() );
    	}
    
    	$user = get_user_by( 'id', $user );
    	$user->add_cap( 'administrator' );
    
    }, 999 );
Viewing 1 replies (of 1 total)