Fix on register users
This commit is contained in:
@@ -186,8 +186,8 @@ class Opalestate_User_Form_Handler {
|
||||
if ( $password !== $password1 ) {
|
||||
throw new Exception( '<strong>' . esc_html__( 'ERROR', 'opalestate-pro' ) . ':</strong> ' . esc_html__( 'Re-Password is not match.', 'opalestate-pro' ) );
|
||||
}
|
||||
$credentials['user_pass'] = $password;
|
||||
|
||||
$credentials['user_pass'] = $password;
|
||||
|
||||
/* create new user */
|
||||
$user_id = opalestate_create_user( $credentials );
|
||||
@@ -195,8 +195,7 @@ class Opalestate_User_Form_Handler {
|
||||
if ( is_wp_error( $user_id ) ) {
|
||||
throw new Exception( '<strong>' . esc_html__( 'ERROR', 'opalestate-pro' ) . ':</strong> ' . $user_id->get_error_message() );
|
||||
} else {
|
||||
|
||||
/* after register successfully */
|
||||
/* After register successfully */
|
||||
do_action( 'opalestate_after_register_successfully', $user_id );
|
||||
|
||||
$redirect = home_url();
|
||||
@@ -213,7 +212,7 @@ class Opalestate_User_Form_Handler {
|
||||
|
||||
$redirect = apply_filters( 'opalestate_register_redirect_url', $redirect );
|
||||
|
||||
/* is ajax request */
|
||||
/* Is ajax request */
|
||||
if ( opalestate_is_ajax_request() ) {
|
||||
wp_send_json( [ 'status' => true, 'redirect' => $redirect ] );
|
||||
} else {
|
||||
|
||||
@@ -185,20 +185,24 @@ class OpalEstate_User {
|
||||
}
|
||||
|
||||
/**
|
||||
* On Register user.
|
||||
*
|
||||
* @param int $user_id User ID
|
||||
*/
|
||||
public function on_regiser_user( $user_id ) {
|
||||
if ( isset( $_POST['role'] ) ) {
|
||||
$roles = opalestate_user_roles_by_user_id( $user_id );
|
||||
|
||||
// Fetch the WP_User object of our user.
|
||||
$u = new WP_User( $user_id );
|
||||
$u->remove_role( 'subscriber' );
|
||||
|
||||
// Replace the current role with 'editor' role
|
||||
$u->set_role( sanitize_text_field( $_POST['role'] ) );
|
||||
|
||||
$roles = opalestate_user_roles_by_user_id( $user_id );
|
||||
|
||||
if ( $roles && in_array( $_POST['role'], $roles ) ) {
|
||||
$role = str_replace( 'opalestate_', '', sanitize_text_field( $_POST['role'] ) );
|
||||
|
||||
do_action( 'opalestate_on_set_role_' . $role, $user_id );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user