WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The wordpress function wp_insert_user doesn't seem to set (overwrite) the input I give. (documentation shows you can't) Trying to use: wp_insert_user using the returned userID also doesn't work.

Of course I could just make my own query but maybe I'm forgetting an option to insert this data using a existing function.

$userdata = array(
    //user login
    'user_pass'  => esc_attr( $_POST['pass'] ),
    'user_login' => esc_attr( $_POST['user'] ),
    'user_email' => esc_attr( $_POST['email'] ),

    //user meta
    'rich_editing' => false,
    'comment_shortcuts' => false,
    'show_admin_bar_front' => false,        
    'wp_user_level' => 0, 
    'wp_capabilities' => 'a:1:{s:10:"subscriber";s:1:"1";}' 

     $new_user_user_id = wp_insert_user( $userdata );   
share|improve this question
up vote 4 down vote accepted

What you are best off doing is hooking into user_register and from there updating the user options you want them set to. Below is an example of disabling the admin bar for new users:

add_action("user_register", "sc_set_user_admin_bar_false_by_default", 10, 1);
function sc_set_user_admin_bar_false_by_default($user_id) {
    update_user_meta( $user_id, 'show_admin_bar_front', 'false' );
    update_user_meta( $user_id, 'show_admin_bar_admin', 'false' );
share|improve this answer

The codex page for wp_insert_user() lists all the values that it accepts. comment_shortcuts, and show_admin_bar_front will all need to be set with update_user_meta().

To handle wp_user_level and wp_capabilities you will need to use WP_User.

You can use $new_user_user_id (long var name lol) for both WP_User and update_user_meta()

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.