• 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.

    https://www.ads-software.com/extend/plugins/add-multiple-users/

Viewing 1 replies (of 1 total)
  • Thread Starter daniel_henrique

    (@daniel_henrique)

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Add Multiple Users for WordPress] Hook user_register, user role and AMU’ is closed to new replies.