WordPress.org

Support

Support » How-To and Troubleshooting » wp_inser_user and role issue

wp_inser_user and role issue

  • Hello,

    I use below code to add new user. Everything works fine except that I am not able to set role of the new_user by my own. What I am doing wrong?

    require('./wp-blog-header.php');
    require('./wp-includes/registration.php');
    $new_user = array();
    $new_user['user_pass'] = 'someone';
    $new_user['user_login'] = 'someone';
    $new_user['user_email'] = 'someone@somewhere.here';
    $new_user['display_name'] = 'someone';
    $new_user['role'] = 'editor';
    wp_insert_user($new_user);
Viewing 2 replies - 1 through 2 (of 2 total)
  • Ach, I forgot to mention, that when I use presented code, users become subscribers insted of being editors…

    Te falta :
    require_once(“../../../wp-config.php”);
    require_once(“../../../wp-includes/registration.php”);

    🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_inser_user and role issue’ is closed to new replies.
Skip to toolbar