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
- Redirecting after login except for a specific page
- 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]
- Is it possible to use a forgot password url filter?
- 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 do I redirect all 404 error url to Subcategory url
- How to change login labels
- How to Display Frontend CSS for Administrator only
- Login/logout in header
- 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
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- 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
- Redirect to one of two pages after data submitted, depending on the current url
- How to replace ACTION url from original wordpress login form?
- How to display my comment count in the wordpress admin bar?
- Unable to login after registration
- 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
- How to create a function to redirect a specified page to another page
- Multisite Admin Roles
- Login functions
- Language switcher for subdomains
- WordPress permanently logging users out
- Logging back into WordPress after logging out and having issues with ‘loggedout=true’ in redirect URL
- Allow the access over wp-login.php
- WP Logs me out after updating anything on dashboard
- function to return comma separated list of meta values
- 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?
- Template Redirect Function Only Working When Logged In
- Disable Attachment Page Except for Category
- Simple way to make most of my site private
- wp_login_form display no styled form