• Resolved HeavenCore

    (@heavencore)


    Hi there,

    When creating a new user in code via wp_insert_user() – how does one specify false for the “Show Toolbar when viewing site” setting found under the default WordPress Admin GUI?

    My code thus far:

    $userdata = array(
            'user_login'    =>  $Email,
            'user_pass'     =>  $Password,
            'user_email'    =>  $Email,
            'display_name'  =>  $FirstName . " " . $LastName,
            'nickname'      =>  $FirstName,
            'first_name'    =>  $FirstName,
            'last_name'     =>  $LastName,
            'description'   =>  'Created via custom Registration Page - ' . date("YmdHis")
        );
    
        //#### Create the WordPress user
        $user_id = wp_insert_user( $userdata ) ;
    
        //#### Check user was created OK, if not, return error, if so, return userID
        if( is_wp_error($user_id) ) {
            custom_ajax_exit("ERROR:" . $user_id->get_error_message());
        } else {
            custom_ajax_exit("OK:" . $user_id);
        }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Make an entry in usermeta like so:
    update_user_meta( $user_id, 'show_admin_bar_front', false );

    Thread Starter HeavenCore

    (@heavencore)

    cheers bcworkz, tried that but it would not work for love nor money!

    Turns out I needed to pass false as a string instead of a boolean, i.e:

    update_user_meta( $user_id, 'show_admin_bar_front', 'false' );

    instead of:

    update_user_meta( $user_id, 'show_admin_bar_front', false );

    Just thought id share this in case anyone else runs into the same problem.

    Regards

    J.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘"Show Toolbar when viewing site" & wp_insert_user()’ is closed to new replies.