WordPress.org

Ready to get started?Download WordPress

Forums

Add Multiple Users for WordPress
Hook user_register, user role and AMU (2 posts)

  1. daniel_henrique
    Member
    Posted 1 year ago #

    Hi.

    AMU is using wp_create_user instead of wp_insert_user. When wp_create_user is called, the default role is used instead of the role specified for each user, and my user_register hook(that depends on a specific user role) fails.

    I was able to work around this limitation by changing add-multiple-users/functions/commonfn.php:

    //passes all checks, create new user
    		} else {
    			//$addnewuser = wp_create_user($this->user_login, $this->user_pass, $this->user_email);
                            $userdata = (array) $this;
    onbiz_log('$userdata', $userdata);
                            $userdata['user_login'] = esc_sql( $userdata['user_login'] );
                            $userdata['user_email'] = esc_sql( $userdata['user_email'] );
                            $addnewuser = wp_insert_user($userdata);

    It seemed to work.
    Is it safe to use wp_insert_user? Is there a reason to use wp_create_user? Can the plugin be changed?

    Thanks in advance.

    Best regards,

    Daniel.

    http://wordpress.org/extend/plugins/add-multiple-users/

  2. daniel_henrique
    Member
    Posted 1 year ago #

    onbiz_log is just a log function. The code will work without it.

    //passes all checks, create new user
    		} else {
    			//$addnewuser = wp_create_user($this->user_login, $this->user_pass, $this->user_email);
                            $userdata = (array) $this;
                            $userdata['user_login'] = esc_sql( $userdata['user_login'] );
                            $userdata['user_email'] = esc_sql( $userdata['user_email'] );
                            $addnewuser = wp_insert_user($userdata);

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic