you can do that with this code (paste it to your functions.php)
function auto_redirect_external_after_logout(){
// check if user is leaving from admin
// is_admin() check would not work here probably as we left the admin already
if ( false !== strpos( $_SERVER['HTTP_REFERER'], 'wp-admin' ) ){
wp_redirect( 'http://www.example-from-admin.com' );
} else {
wp_redirect( 'http://www.example-from-front.com' );
}
//make sure to call exit after redirect
exit;
}
//execute the code above on logout
add_action( 'wp_logout', 'auto_redirect_external_after_logout');
Related Posts:
- Masking logout URL
- Logout/login redirect CSS issue
- redirect wp-login.php to another page
- How do I redirect upon login a specific user based on role?
- Login Redirect if Logged in from Specific Page
- Add Login and logout buttons to top menu bar
- How to redirect Subscribers on login to specific page, when logging in from a Page
- How to request login for user but not for bots
- wp_enqueue_script was called incorrectly
- How do I get the current edit page ID in the admin?
- How to change the default logout link on WordPress Admin
- Modify Admin Bar Link
- Logout redirect to current page – function
- How to remove row-actions from pages table?
- Is it possible to remove the main rich Text box editor?
- Add admin bar link to edit author
- handling login/logout redirects
- How can I tell if I’m on a login page? [duplicate]
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- Replacing select2 in admin backend for all selects
- echo or print_r in an admin function
- Can I remove the Rich Text box editor for a specific post?
- Login using the password from protected pages
- Logging in redirects to correct page but shows logged out content until forced refresh
- Redirect user after logout
- wordpress custom login successful redirect hook
- I keep getting logged out in Firefox
- How to add a column to the Trash page?
- How to test for Super Admin
- Remove default user registration, login and subscriber profiles
- is_user_logged_in not working to redirect only logged out users
- How to select a page within admin?
- Members only site – still need the lost password page accessible
- Change Admin Bar “Visit Site” URL
- Ninja form Redirect depending on text field content [closed]
- Redirect specific page in WordPress for first time visit
- How to Display Frontend CSS for Administrator only
- Login/logout in header
- Hard-coding custom menu elements for menu manager
- How to make custom column Admin>Users sortable?
- How can I get my Script to work on the Login page?
- Trigger a custom function when option are saved in admin area
- 404 redirect to previous category
- Force to use STRONG users password and implement rule to prevent REUSE [closed]
- WordPress Admin Login Redirect Problem
- Unable to login using username
- When a user logs in, how can they view the website instead of the admin menu?
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Get User Login Data (date, time… )
- Incorrect redirect after commenting
- How i can put $_GET codes in function.php?
- If user is logged-in display/hide something
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- Can’t login to my admin area
- Page get parameter doesn’t work with is_single() function
- Secondary Menu and Logged In Users
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- Contact Form 7 If Condition
- Prevent WordPress Automatic Logout
- error at login page in wordpress
- Solved: redirect to another page using functions.php
- Redirect to other page if login
- logout redirect only from admin page
- How to add array [closed]
- what is best way to keep track of changes made in wordpress website? [closed]
- WordPress wraps span tags into p tags
- WordPress website keeps loading the maintenance page
- Redirects based on a JSON file
- loginout function customization
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- Show errormessages on wrong username/password on custom loginform?
- template_redirect action only firing if logged in
- Removing WPML Items From the WordPress Admin Bar
- WordPress login set cookie that survive browser exit (wp_signon function)
- This code is supposed to only allow user to be authenticated if accountVerified is equal to 1, but it still allows user to be authenticated otherwise
- Prevent wp_signon redirect on failed login for ajax login
- Show metadata in users.php – wordpress
- How to display my comment count in the wordpress admin bar?
- Allow logged in user to view a Page, else send to login screen and then redirect back to Page
- Wildcard 301 Redirect Using Theme Function
- Competing Login Redirects – Need to be Combined?
- Postback redirect through add_action is not triggered
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Restrict access if logged out except for homepage
- Redirect specific author posts to another url
- Trying to login to my site redirects me to the first page
- Custom download page
- Redirect after login to current URL
- Login functions
- Language switcher for subdomains
- WordPress permanently logging users out
- Allow the access over wp-login.php
- WP Logs me out after updating anything on dashboard
- Screen Options WordPress WYSIWYG
- is_user_logged_in() isn’t working
- update_user_option not working as expected
- “Headers already sent” while trying to add a CSS file to my login page?
- Making an under maintenance page (without using plugins)
- Logout redirect via page template without confirmation?
- Disable Attachment Page Except for Category