Svetlozar
Svetlozar

Reputation: 987

show_admin_bar_front => false doesn't work

I'm inserting a user with 'show_admin_bar_front' => false. When I login, the admin bar is still there. Can someone tell me why?

$user = wp_insert_user( array (
        'user_login' =>  crb_get_nicname( $_POST['first_name'], 
$_POST['last_name'] ),
        'user_email' =>  $_POST['email'],
        'user_pass' =>  $_POST['password'],
        'first_name' =>  $_POST['first_name'],
        'last_name' =>  $_POST['last_name'],
        'role' =>  $_POST['role'],
        'show_admin_bar_front' => false
    ) );

Upvotes: 1

Views: 1961

Answers (1)

DasSaffe
DasSaffe

Reputation: 2198

Even though I can't tell you why exactly that is, I can tell you, that you have to use a string, instead of a boolean. The docs seems to be wrong on that option.

$user = wp_insert_user( array (
        'user_login' =>  crb_get_nicname( $_POST['first_name'], 
$_POST['last_name'] ),
        'user_email' =>  $_POST['email'],
        'user_pass' =>  $_POST['password'],
        'first_name' =>  $_POST['first_name'],
        'last_name' =>  $_POST['last_name'],
        'role' =>  $_POST['role'],
        'show_admin_bar_front' => "false" // <-- now as string
    ));

As said before, the docs state:

show_admin_bar_front

(string|bool) Whether to display the Admin Bar for the user on the site's front end. Default true.

But bool simply isn't accepted here.

Upvotes: 11

Related Questions