I want to redirect user to another page if they are logged in.
Here is what I have so far.
If logged in = Redirect to another page.
If not logged in = Show this form.
[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]
Redirect user to another page.
[/wpv-conditional]
[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]
[cred_user_form form="teardrop-flag-form"]
[/wpv-conditional]
I manage to solve it with this code.
function redirect_to_specific_page() {
if ( is_user_logged_in() && is_page( 1012 ) )
{
wp_redirect( get_permalink( 44 ) );
exit;
}
}
add_action( 'template_redirect', 'redirect_to_specific_page' );
Not the most efficient way but it gets the job done.
Now I need to duplicate this for each page that I have because the redirect is unique for each page.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
It seems you have used the correct hook now you need to add if and else conditions within that hook to check with your multiple pages and add redirection accordingly.
How would use the else function?
Currently, I am using Conditional Output if isn't logged in.
[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]
[cred_user_form form="teardrop-flag-form"]
[/wpv-conditional]
What do you think?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
There is no else condition but you should check if value is equal to or not equal to.
For example:
[wpv-conditional if="( '[wpv-current-user info='logged_in']' ne 'false' )"]
[cred_user_form form="teardrop-flag-form"]
[/wpv-conditional]
My issue is resolved now. Thank you!