Simple Membership Plugin › Forums › Simple Membership Plugin › Logout redirection
Tagged: Logout, redirection
- This topic has 9 replies, 6 voices, and was last updated 7 years, 3 months ago by
mbrsolution.
-
AuthorPosts
-
June 10, 2015 at 2:02 pm #2036
StudioBizz
ParticipantHello,
When user logout, he his redirected to the site Homepage. How can we redirect him to a specific page ?
Thanks again 😉
July 4, 2015 at 7:23 pm #2239uxpractice
Participant**Bump** Looking for this exact solution. Have yet to dive into the code. Would rather have a scalable option (something in functions.php rather than hacking to plugin (for updating).
I’m using the custom logout URL you’ve provided and looking to send (redirect) the user to login page after logging out. Any takers?
July 6, 2015 at 11:17 am #2244StudioBizz
ParticipantI am ! If you can find a way to do this, it would be wonderful !
July 7, 2015 at 4:21 am #2253admin
KeymasterYou can use the following tweak to do a custom redirection after the logout event.
Add the following code to your theme’s functions.php file and that should do the job:
add_action('swpm_logout', 'my_custom_after_logout_redirection'); function my_custom_after_logout_redirection() { $url = 'http://www.example.com/after-logout-page';//TODO - Specify the URL that you want to redirect to wp_redirect($url); }July 7, 2015 at 4:32 am #2257admin
KeymasterYou can add that code to a small custom plugin also (instead of your theme’s template file).
January 5, 2016 at 9:06 pm #4774hwbmeuk
ParticipantHi Admin
I have used your ‘add_action’ in my child theme and also (as a test – in the parent theme) – it doesn’t work in either place. Has there been an improvement in this code since July?
Where is the original function managed, within the plugin? or can the logout URL be edited from the plugin admin interface?
Dumping users at the home page is a bit frustrating for users if I have messages and content at the login page which are useful for the user.
regards
HowardJanuary 6, 2016 at 1:13 am #4776mbrsolution
ModeratorHi Howard try adding the following line exit(); at the end. That should work because I carried out a test with and with out that line. It definitely works with that line added.
See the following code.
add_action('swpm_logout', 'my_custom_after_logout_redirection'); function my_custom_after_logout_redirection() { $url = 'http://www.example.com/after-logout-page';//TODO - Specify the URL that you want to redirect to wp_redirect($url); exit(); }January 6, 2016 at 8:27 am #4779hwbmeuk
ParticipantBrilliant.
This worked perfectly … many thanks
🙂
July 26, 2018 at 9:26 am #15015sflosamuel
ParticipantMy website has 3 languages. I use wpml plugin.
How can I redirect member to 3 languages index page respectively after logout?July 26, 2018 at 11:39 pm #15025mbrsolution
ModeratorHi @sflosamuel, unfortunately at present there is no addon or integration with WPML plugin. If you are a developer, you might like to tweak the above code to improve the function to include other options when login out.
Or you can also request for paid support.
Regards
-
AuthorPosts
- You must be logged in to reply to this topic.