WordPress.org

Forums

wp_inser_user and role issue (3 posts)

  1. mO_m
    Member
    Posted 6 years ago #

    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);
  2. mO_m
    Member
    Posted 6 years ago #

    Ach, I forgot to mention, that when I use presented code, users become subscribers insted of being editors...

  3. ubilla
    Member
    Posted 5 years ago #

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

    :)

Topic Closed

This topic has been closed to new replies.

About this Topic