• miocene22

    (@miocene22)


    I’m slightly modifying a plugin that allows people to ‘subscribe’ by entering their Name and email into a form. This data is then used to create a subscriber-level user in the wordpress users database.

    I’ve used the following code to acheive this.

    $user_pass = substr( md5( uniqid( microtime() ) ), 0, 7);
    
    $user_id = wp_create_user( $user_login, $user_pass, $user_email );
    
    $user = new WP_User($user_id);
    $user->set_role('subscriber');
    wp_insert_user( array ('ID' => $user_id, 'first_name' => $userName) ) ;

    It basically sets the username as the first part of the email address, generates a random password. The problem I’m having is setting the first name as the name they entered ($userName is defined as what the person subscribing typed in as their name). It all works except the bit adding the first name. Currently the wp_insert_user() function just doesn’t do anything.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Adding a new user’ is closed to new replies.