Hi @amateurhr
I don’t know which plugin you are using to set the redirect. How to inject dynamic data to the redirect url will depend on the plugin, allways assuming that it has some sort of support for it.
Alternatively, you can use a small custom code in your theme functions.php file to redirect users immediately after the login.
I made this snippet for you:
function my_allowed_redirect_hosts($content){
$content[] = 'example.com';
return $content;
}
add_filter( 'allowed_redirect_hosts' , 'my_allowed_redirect_hosts' , 10 );
function my_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
if (!empty($user->data)) {
$user_first_name = get_user_meta($user->ID, 'first_name', true);
$user_last_name = get_user_meta($user->ID, 'last_name', true);
$url_parameters = array(
'name' => $user_first_name,
'email' => $user->data->user_email,
'last_name' => $user_last_name,
);
$base_redirect_url = 'http://example.com/waitlist/';
$redirect_to = add_query_arg( $url_parameters, $base_redirect_url );
/*var_dump($redirect_to);
die();*/
}
return $redirect_to;
}
add_filter( 'login_redirect', 'my_login_redirect', 20, 3 );
Paste it inside functions.php and disable the redirect plugin that you are using.
Let me know if that works for you.
Take care
@sjaure I appreciate your help on this. Do you have any idea how to modify the code you wrote above to use for registration (not login)? I can disable the redirect on my registration forms (I currently use Formidable/NextEnd Social).
Thank you!
Hey @amateurhr
I don’t have time to adapt the code right now, but you should be able to adapt it to use this hook: https://codex.wordpress.org/Plugin_API/Filter_Reference/registration_redirect