Your logic is not quite correct as in some cases you will never hit the one return statement. Try this instead:
function custom_login_redirect( $redirect_to, $request, $user ) {
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( 'administrator', $user->roles ) || in_array( 'editor', $user->roles ) || in_array( 'author', $user->roles ) ) {
return $redirect_to;
} else {
if ( in_array( 'subscriber', $user->roles ) && is_page() ) {
return home_url('/member-resources/');
}
} else {
return $redirect_to;
}
}
add_filter( 'login_redirect', 'custom_login_redirect', 10, 3 );
Related Posts:
- Masking logout URL
- 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
- Logout Redirect and also WP-login.php Redirect
- How to request login for user but not for bots
- Redirecting after login except for a specific page
- wp_enqueue_script was called incorrectly
- Logout/login redirect CSS issue
- 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
- Login using the password from protected pages
- Logging in redirects to correct page but shows logged out content until forced refresh
- wordpress custom login successful redirect hook
- Remove default user registration, login and subscriber profiles
- is_user_logged_in not working to redirect only logged out users
- Members only site – still need the lost password page accessible
- 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 can I get my Script to work on the Login page?
- 404 redirect to previous category
- 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
- WordPress PHP Conflicting User Sessions
- Get User Login Data (date, time… )
- Incorrect redirect after commenting
- Registration Hooks don’t appear to be working
- 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?
- 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]
- How to add array [closed]
- WordPress website keeps loading the maintenance page
- Redirects based on a JSON file
- loginout function customization
- Add Login and logout buttons to top menu bar
- Show errormessages on wrong username/password on custom loginform?
- template_redirect action only firing if logged in
- 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
- Redirect to one of two pages after data submitted, depending on the current url
- How to replace ACTION url from original wordpress login form?
- 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
- Custom download page
- Redirect after login to current URL
- How to create a function to redirect a specified page to another page
- Login functions
- Language switcher for subdomains
- WordPress permanently logging users out
- Allow the access over wp-login.php
- 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)
- 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
- How to redirect using a custom wordpress api endpoint after form submission?
- add_menu_page() with variable function
- How to setup a popup registeration page in wordpress with function.php
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Featured Image keeps cropping
- Function Suddenly Stopped Working
- Redirect certain pages if user logged in
- Prevent creating multiple image resizes in twentytwelve template
- Why is this function crashing my wordpress installation? [closed]
- Dashboard blocker on network multisite for specific user roles
- Shortcode of a function
- How to place a div inside a function that creates a div
- Echo post title in post
- Unable to Change “Pages:” Before WP_LINK_PAGES
- colorbox not loading in
- dynamic enquiry form [closed]
- wp_get_archives() output
- I would like single.php to act just like index.php
- WP Admin Login keeps redirecting to login
- Conditional function for excluding first image from content, not working
- Does WordPress has an automatic link parse function?
- Fatal error: allowed memory size when after using enqueue_script