Skip Navigation

[Resolved] Redirecting logged in users

This support ticket is created 4 years, 5 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 4 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#1372941

Hi there,

I'm trying to figure out how to redirect users if they are already logged in.

For example, i want to create a landing home page to gather users which is hidden to logged in users. If they're are already logged in, how can I redirect them to another page?

#1373021

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Kyle

That's not really a Toolset question.

You need to add a PHP snippet (which you can add at Toolset > Settings > Custom Code) that checks if the current page is the one you want to target, checks if there is a logged-in user, and if so performs a redirect.

The earliest hook you should use to add your code is the 'wp' hook (https://codex.wordpress.org/Plugin_API/Action_Reference/wp).

You can test the current page with is_page() (https://developer.wordpress.org/reference/functions/is_page/)

You can test if there is a logged-in user with is_user_logged_in() (https://developer.wordpress.org/reference/functions/is_user_logged_in/)

You can use wp_redirect to redirect to another page (https://developer.wordpress.org/reference/functions/wp_redirect/).

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.