• mo_m

    (@mo_m)


    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'] = '[email protected]';
    $new_user['display_name'] = 'someone';
    $new_user['role'] = 'editor';
    wp_insert_user($new_user);
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mo_m

    (@mo_m)

    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.