mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-18 06:03:38 +09:00
- fixed user status setup on registration process;
This commit is contained in:
@@ -465,8 +465,9 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
$global_role = get_option( 'default_role' ); // WP Global settings
|
||||
|
||||
$um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings
|
||||
if ( ! empty( $um_global_role ) )
|
||||
if ( ! empty( $um_global_role ) ) {
|
||||
$global_role = $um_global_role; // Form Global settings
|
||||
}
|
||||
|
||||
|
||||
$mode = $this->form_type( $post_id );
|
||||
|
||||
@@ -1661,23 +1661,29 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update user
|
||||
if ( count( $args ) > 1 ) {
|
||||
global $wp_roles;
|
||||
$um_roles = get_option( 'um_roles' );
|
||||
|
||||
if ( ! empty( $um_roles ) ) {
|
||||
$role_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, get_option( 'um_roles' ) );
|
||||
} else {
|
||||
$role_keys = array();
|
||||
}
|
||||
//if isset roles argument validate role to properly for security reasons
|
||||
if ( isset( $args['role'] ) ) {
|
||||
global $wp_roles;
|
||||
$um_roles = get_option( 'um_roles' );
|
||||
|
||||
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
||||
if ( ! empty( $um_roles ) ) {
|
||||
$role_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, get_option( 'um_roles' ) );
|
||||
} else {
|
||||
$role_keys = array();
|
||||
}
|
||||
|
||||
if ( isset( $args['role'] ) && in_array( $args['role'], $exclude_roles ) ) {
|
||||
unset( $args['role'] );
|
||||
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
||||
|
||||
if ( in_array( $args['role'], $exclude_roles ) ) {
|
||||
unset( $args['role'] );
|
||||
}
|
||||
}
|
||||
|
||||
wp_update_user( $args );
|
||||
|
||||
@@ -55,7 +55,7 @@ function um_after_insert_user( $user_id, $args ) {
|
||||
UM()->user()->remove_cached_queue();
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
UM()->user()->set_status( um_user('status') );
|
||||
UM()->user()->set_status( um_user( 'status' ) );
|
||||
if ( ! empty( $args['submitted'] ) ) {
|
||||
UM()->user()->set_registration_details( $args['submitted'] );
|
||||
}
|
||||
@@ -369,6 +369,30 @@ function um_submit_form_register( $args ) {
|
||||
$args['submitted'] = array_merge( $args['submitted'], $credentials );
|
||||
$args = array_merge( $args, $credentials );
|
||||
|
||||
//get user role from global or form's settings
|
||||
$user_role = UM()->form()->assigned_role( UM()->form()->form_id );
|
||||
|
||||
//get user role from field Role dropdown or radio
|
||||
if ( isset( $args['role'] ) ) {
|
||||
global $wp_roles;
|
||||
$um_roles = get_option( 'um_roles' );
|
||||
|
||||
if ( ! empty( $um_roles ) ) {
|
||||
$role_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, get_option( 'um_roles' ) );
|
||||
} else {
|
||||
$role_keys = array();
|
||||
}
|
||||
|
||||
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
||||
|
||||
//if role is properly set it
|
||||
if ( ! in_array( $args['role'], $exclude_roles ) ) {
|
||||
$user_role = $args['role'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
@@ -391,7 +415,7 @@ function um_submit_form_register( $args ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$user_role = apply_filters( 'um_registration_user_role', UM()->form()->assigned_role( UM()->form()->form_id ), $args );
|
||||
$user_role = apply_filters( 'um_registration_user_role', $user_role, $args );
|
||||
|
||||
$userdata = array(
|
||||
'user_login' => $user_login,
|
||||
|
||||
Reference in New Issue
Block a user