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
- 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
- Redirect to referring page after logging in
- How to paginate the get_users function?
- Compare post levels and user levels wishlist member
- Change ul class=”children” for wp_list_pages?
- Polylang: pll_e() & pll__() on functions.php, doesn’t work
- Inserting a functions output after the content
- Redirect user to previous page after signup from custom form
- Usage of the login_redirect filter
- get_terms and meta_value results blank
- Dequeue scripts in IE7 only using functions.php
- Featured Image keeps cropping
- Function Suddenly Stopped Working
- Create a CUstom Archive by Year, but just for a Single Category
- Is it possible to load recaptcha script only in url with fragment identifier (#)?
- page shows short code not output
- Prevent function from triggering on current page
- Assign IDs to headings in ACF using functions.php
- Multiple Notifications SetInterval
- Child Theme not loading multiple stylesheets
- Post date on Custom field
- Fatal error: Call to undefined function add_action() – an untouched problem
- Unregistering custom tinymce plugin?
- Combining wp_current_user() and a variable
- Init hook for header send
- site_url is not honoring scheme