Reply To: User login option "Per form"

Home Forums User Registration User login option "Per form" Reply To: User login option "Per form"

#19970

rumesh38
Moderator

Hi Josh,

There is no option to select a different login option for the registration form. But there is a way around for your case if you are comfortable using the code. You can add the following code in the function.php file of your theme to approve users registered through the specific form.

function ur_set_user_status( $valid_form_data, $form_id, $user_id ) {

	$user_manager = new UR_Admin_User_Manager( $user_id );

	$alert_user_email = false; // Set true to send email to user for approval.

	if ( in_array( $form_id, array( '<Your form ID to be approved>' ) ) ) { // [user_registration_form id = "<Your form ID>"]
		$user_manager->save_status( UR_Admin_User_Manager::APPROVED, $alert_user_email );
		wp_clear_auth_cookie();
		wp_set_auth_cookie( $user_id );
	}
}
add_action( 'user_registration_after_register_user_action', 'ur_set_user_status', 20, 3 );

function ur_user_register_status( $success_params, $valid_form_data, $form_id, $user_id ) {
	if ( in_array( $form_id, array( '<Your form ID to be approved>' ) ) ) { // [user_registration_form id = "<Your form ID>"]
		$success_params['auto_login'] = true;
	}

	return $success_params;
}
add_filter( 'user_registration_success_params', 'ur_user_register_status', 10, 4 );

Hope this help!

Thanks & Regards,
WPEverest Support Team.