All you have to do is copy the part in the code that checks which role the user has and redirect somewhere else, like this:
function redirect_after_logout( $user_id ) {
$current_user = get_user_by( 'id', $user_id );
$role_name = $current_user->roles[0];
if( $role_name == 'administrator' ) {
wp_safe_redirect( site_url( '/login/' ) );
exit;
}
if( $role_name == 'ANOTHER_ROLE' ) {
wp_safe_redirect( 'URL_WHERE_EVER_YOU_WANT_TO_REDIRECT' );
exit;
}
}
add_action( 'wp_logout', 'redirect_after_logout' );
Related Posts:
- How do I make a redirect in PHP?
- PHP – redirect https to http and www to non-www
- Redirect to Page after Post Submit
- How to redirect users to custom lostpassword page?
- Insert code when users come from an specific referer
- How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
- Is Auto Post recognition a WordPress feature? How to turn it off?
- WordPress template_include filter not working properly
- Logout and redirect using the WP Menu
- Change links automatically to affiliate links
- PHP If user is logged in & on home page redirect
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- WordPress does not load page.php, return 404.php
- 3 blogs same installation, without WP MU
- WordPress homepage infinite redirect
- Redirect undesirable domain
- How do I display the main domain for my WordPress install?
- Problem with login form
- Set Cache-Control header for 301 redirects
- How to redirect users based on role and content of redirect_to?
- Moving code from theme header to functions.php
- Showing latest post without 301 redirect
- Having Issue on Redirecting With Session in WordPress
- Using a $GET parameter from a URL, to redirect to a URL (WordPress)
- WordPress redirect redirecting too many times or not at all
- Using Argument from Function to Re-Direct Visitor (WordPress)
- I am receiving a pluggable.php warning sign on my only http:// page
- Login redirect. Check user meta and redirect accordingly
- Where to insert redirect code based on http_referer?
- Is this a correct usage of ob_start() in my WordPress project?
- How to allow download url redirection only if user logged in WordPress site?
- PHP Redirect condition
- Manually Create PHP Page For A Redirect
- Redirect to current user page upon link click
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- Writing a link cloaking plugin
- WordPress permalink issue
- WP insert post Redirect after function has executed
- How to redirect non logged in mobile users to page on same site?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Download file and redirect to page or vice versa
- 404 on old link after changing post url
- WordPress url By country code?
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
- WordPress on Ubuntu – “File not Found” for home.php – Trying to Redirect to Root Folder
- Remove all feeds and return custom 404 page
- Infinite loop when logging out using custom login form
- Redirect User when they click Menu Option
- WordPress: Redirect Main Site to Subsite in Multisite Where user is NOT logged in
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- wp-login.php?redirect_to=https problem
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- WordPress Redirect / Add_Rewrite_Rule – Non Index.php Page
- Override 404 when navigating to single php file
- Submit to itself don’t work
- redirect 301 with special character like WIX site “#!”
- 301 redirect from webpage to wordpress page in the same root
- Submitting my form to the database and then redirecting to payment site
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- Get permalink for a post from inside WordPress and route to a related site
- Redirect users not logged in to the standard login page (and back) from some posts and pages
- Link to external page has wordpress blog-url inside
- How to use multiple 404 Error Pages in WordPress
- How to create a WordPress PAGE in another folder?
- index.php file keeps redirecting to a non-existent index.html file?
- Redirect loop upon installation of my plugin
- wp_login_url always redirects me to wp-admin
- Where to get information about array fields in $_REQUEST?
- Problems with function on function.php
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- WordPress: Remove link in the_tags
- Set WP_MAX_MEMORY_LIMIT higher than PHP.ini memory_limit
- Apache Fallback instead of add_rewrite_rule
- Correct folder permissions?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How can I add extra word in permalink when someone click download button?
- Why WordPress won’t update via VPN?
- Create custom permalinks to show Custom Post Type’s relationship?
- Code Executing Too Late?
- New walker for walker_nav_menu to change inside container data
- Isotope Drop Down Categories Filter Function
- Getting users with a specific meta data and then querying their posts?
- Select through customizer the template part to be viewed
- Nav-Menu not showing up
- Showing Subcategory Name/Link Instead of Parent Category
- Get URI from PodPress using PHP
- How to pass hook variable to function?
- Update Images after edit via php
- custom mailchimp form using HTTP API
- WordPress Recent Posts – Loop
- Changing default WPMU emails to be send thorugh Campaign Monitor Transactional emails
- not able to access $_POST on backend profile update
- WordPress Single Post Pagination Numbered and Navigational
- Post formating on Home page
- Search box background on a different page template
- Edit Image/Image Details – Replace button missing
- get user role. parameter id return type string [closed]
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- links Slick jS library using wp_enqueue_scripts not pulling