Login and logout redirection
-
I have had a really good look around this site and many others, and I haven’t worked out this issue yet.
Rather than modify the core code as I have done in the past I am now developing some of my hacks into plugins.
One such simple function is redirection on login to homepage, which works perfectly fine with the following code bundled into a plugin (credit to WP community, not sure where I got this from!)
<?php function MCMSlogin_redirect () { global $redirect_to; if ( ! current_user_can('edit_posts') ) $redirect_to = get_option('home'); } add_action('wp_authenticate', 'MCMSlogin_redirect'); ?>
So, when wp_authenticate runs it sends the user back to the homepage rather than straight to the dashboard.
However, I don’t seem to be able to do this with logout. I have done some research and have tried using wp_logout – but further research has told me that ‘this is an action that is fired when a user is logging out and executes just after wp_clearcookie() runs and before the user is redirected’ – which is obviously not going to do what I want!
I have also had a look at ‘loginout’ – but can’t really find any documentation on this.
Does anyone have any ideas on how to re-direct on logout?
I know there are a couple of plugins that do this, but I am really trying hard to learn about WP and would love to see one of you code ninjas come up with a solution to this simple problem I am having!
- The topic ‘Login and logout redirection’ is closed to new replies.