mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Fixed: Role validation on registration.
WordPress uses the default user role if the role wasn't chosen in the registration form. That is why we should use submitted data to validate fields Roles (Radio) and Roles (Dropdown).
This commit is contained in:
@@ -457,10 +457,10 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
||||
}
|
||||
|
||||
if ( $key == 'role_select' || $key == 'role_radio' ) {
|
||||
if ( isset( $array['required'] ) && $array['required'] == 1 && ( ! isset( $args['role'] ) || empty( $args['role'] ) ) ) {
|
||||
UM()->form()->add_error( 'role', __( 'Please specify account type.', 'ultimate-member' ) );
|
||||
}
|
||||
/* WordPress uses the default user role if the role wasn't chosen in the registration form. That is why we should use submitted data to validate fields Roles (Radio) and Roles (Dropdown). */
|
||||
if ( in_array( $key, array( 'role_radio', 'role_select' ) ) && isset( $array['required'] ) && $array['required'] == 1 && empty( UM()->form()->post_form['submitted']['role'] ) ) {
|
||||
UM()->form()->add_error( 'role', __( 'Please specify account type.', 'ultimate-member' ) );
|
||||
UM()->form()->post_form[$key] = '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user