I've a code for auto-login after registration which is:
function auto_login_new_user( $user_id ) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
$request = $_SERVER["HTTP_REFERER"];
wp_redirect($request);
exit;
}
add_action( 'user_register', 'auto_login_new_user' );
what I need is to create a shortcode to control the time of redirect, I don't want it to redirect after $userID = wp_insert_user( $userDataArr );
I want the redirect to happen after adding some code for extra fields like so update_user_meta( $userID, $fieldsArr[$fieldN], $value);
I was thinking that I can do so by butting the ADD_ACTION code inside shortcode funtion
function my_login_shortcode(){
add_action( 'user_register', 'auto_login_new_user' );
}
add_shortcode('mogincode','my_login_shortcode');
how can I do that ?
Aucun commentaire:
Enregistrer un commentaire