You used in_array
wrong. There might be some redundancy in your function too(depending on what you’re doing). You could use something like this to redirect your users:
add_filter('login_redirect', 'redirect_previous_page', 10);
function redirect_previous_page(){
global $user;
if ( in_array( 'administrator', $user->roles ) ) {
return admin_url();
} else {
return 'http://localhost/'; //add your link here
}
}
Related Posts:
- Disable Or Redirect WP-login.php
- How build a custom login/register form with error handling?
- Multi-steps WordPress registration : in 4 steps how to?
- I want to disable E-Mail verifcation / activation when a user signs up for my WordPress site
- login_enqueue_scripts does not ovewrite the default styles
- Modify wp-login.php labels: Username to Email
- How to change “Registration complete. Please check your e-mail.” in wp-login.php
- How to customise wp-login.php only for users who are setting a password for the first time?
- How can I do customizations on login, registration and password recovery forms?
- How to use wp-login.php page only for logout?
- Redirect user after login/registration globally
- change register url on wp-login page
- Can’t access wp-admin
- How to auto login after registration? [duplicate]
- How do you add a custom link to the wordpress login page?
- wp-login.php register/lost password links to buttons?
- How to trigger a login form notice message?
- Set user password after creating user
- A child theme version of wp-login
- reset password label text change
- Add text on wordpress admin login page
- How do I force “users must be registered and logged in” on subsites?
- How to bypass the username as a required field in registration and just use email address instead?
- Is it possible to remove the version number from the wp-login.php page?
- Anyway to output the registration form like the login form with wp_login_form()?
- wp_login_form() redirect not redirecting users < admin
- WordPress Register Form
- Login redirect on wp theme
- Can’t log in. Log in button missing [closed]
- Require WP login for outside access
- Auto login from custom registration form
- Modify WP-Login Page With Javascript?
- Disabling standard registration login with username/email and password?
- if username or password is incorrect wp-login returns a blank page
- Where is the email content for retrieve_password_message stored?
- What is the CODEX intercept for wp-login.php?action=lostpassword
- Call header and footer on login page
- Prevent redirect on custom wordpress login form
- Replace standard Login and Register form for Woocommerce [closed]
- How to destroy sessions after a user logout [closed]
- How to add required attribute to wp_login_form fields?
- WordPress “remember me” – How should it work?
- Changing the title of “
- Log In & Log Out Code In Header
- How to fix Sign In option in WordPress
- I lock the site’s contents, click on a post, redirect to login, enter uname+password but fail to redirect to article
- How to access the actual input html of the login form
- Creating a custom login on site.
- Login page wordpress tagline remove [duplicate]
- Adding line break in esc_html__
- Copying My account/Login/Register button outside header
- Issue with cookies in wp-login
- Problem in auto login after registration
- Unable to login after registration
- Add content in wp login page
- Is it possible to check if password is correct in wp_authenticate_user?
- Modify login page after clicking “login” button, and before it arrives at redirect
- How to enable “remember me” checkbox in login forms by default?
- Frontend registration form doesn’t save data only redirects to wp-login
- custom login query for custom login form?
- WordPress reCAPTCHA Problem
- Customizing WordPress Login URL
- It is possible that to get data in wp_login.php to your own php file in wordpress?
- Using gettext on wp-login.php won’t change “Back to site name” text
- Add video to wordpress login page
- WordPress login form with fancybox
- I wanna create a custom login form template
- Add custom field in wp_login_form()
- Login user after registration programmatically
- Retrieve password only by login. Users with same email
- wp-login.php not returning error messages / or gives 404
- Registration page background color covering 1 screen not covering full page
- Website visible only to Registered users (non wp-admin)
- Registration fields prefilled with URL parameters
- Custom error messages for login and lost password forms
- Spam Registrations Bypassing WordPress Registration
- WordPress does not allow me to login until another dashboard is open
- Redirect after registration and auto login is not working
- What does this PHP function code mean? [closed]
- How to change the default registration email ? (plugin and/or non-plugin)
- Check if wp-login is current page
- How to display user registration form on front-end of the website?
- Add multiple custom fields to the general settings page
- How can I redirect user after entering wrong password?
- How to allow an user role to create a new user under a role which lower than his level only?
- Is it possible to remove username field from the registration page? If so, how?
- Unable to login and wp-login.php redirects to wp-admin%2F&reauth=1?
- Separate registration and login for different roles
- SSO / authentication integration with external ‘directory service’
- Adding fields to the “Add New User” screen in the dashboard
- users table – user_name vs. nicename
- Disable user registration password email
- What is an easy way to display a front-end user registration form?
- How can I un-reserve a pending username registration?
- How to prefill WordPress registration with social details
- How do I programmatically set default role for new users?
- wordpress redirect after password reset
- Display user registration date
- Customizing the URLs of WordPress Login and Sign-up Pages?
- The website cannot display the page