WordPress.org

Ready to get started?Download WordPress

Forums

Create a new user with user level 3 (2 posts)

  1. leviputna
    Member
    Posted 7 years ago #

    I'm trying to create a new user with user level 3, and having little success.

    I'm using this code in the "register" case on wp-login.php

    $user_id = wp_create_user( $user_login, $user_pass, $user_email );
    wp_new_user_notification($user_id, $user_pass);
    update_usermeta($user_id,'user_level',3);
    wp_redirect('wp-login.php?checkemail=registered');

    but all new users have an user level of 0.
    the email goes out and the page redirects so i know i am running the code.

    Can someone help me out, it seems like a simple problem but it is driving me crazy.

    Thanks in advanced.

  2. cavijayan
    Member
    Posted 7 years ago #

    Hi

    I had the same problem. But i used

    $user_id->set_role('administrator'); //Set the role

    function to set the roles.

    It much easier and it works.

Topic Closed

This topic has been closed to new replies.

About this Topic