Skip Navigation

[Resolved] Redirect Users to Custom Pages by Role

This thread is resolved. Here is a description of the problem and solution.

Problem:
Redirect guest Users to specific URL of Page or post

Solution:
There are many ways you can do it using WordPreass action hooks: "wp" or "template_redirect".

You can find proposed solution with the following reply:
=> https://toolset.com/forums/topic/redirect-users-to-custom-pages-by-role/#post-609177

Relevant Documentation:
https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Pawel Paluch 6 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#608785

Tell us what you are trying to do?
Redirect users to Custom page (NOT layout) based on user Role
For all "guest" user role I would like to redirect them all to specific page url.
Now I can redirect all users using Access Control/Post Groups to specific Template Layout/404 page/Default error
with popup window "What to display for single-posts when there is no read permission"
Is there any way to redirect them all to specific page url.

Is there any documentation that you are following?
Access Control

Is there a similar example that we can see?
N/A

What is the link to your site?
N/A

#608832

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - at what point you want to redirect the guest user?

You mean guest user means any visitor of the site who is not logged in?

#609168

When default user role is "guest" (means user is not registered in system/not logged in). For all registered users I have already setup everything...

#609177

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - there are many ways you can do it using WordPreass action hooks: "wp" or "template_redirect"

For example - Add the code to your current theme's functions.php file:

function login_redirect() {

    // Current Page
    global $pagenow;

    // Check to see if user in not logged in and not on the login page
    if(!is_user_logged_in() && $pagenow != 'wp-login.php')
        wp_redirect( '<em><u>hidden link</u></em>', 302 );
}
// add the block of code above to the WordPress template
add_action( 'wp', 'login_redirect' );

More info:
=> https://stackoverflow.com/questions/11238375/wordpress-redirect-user-if-not-logged-in
=> https://wordpress.stackexchange.com/questions/131879/how-to-redirect-non-logged-in-users-to-a-specific-page
=> https://wordpress.stackexchange.com/questions/131879/how-to-redirect-non-logged-in-users-to-a-specific-page/131926

#611932

Thank you.
I've also resolved problem using third party plugins

🙂