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
- WordPress registration message
- Custom login form redirect to external site
- Registration and Custom Post Types – How to synchronize information?
- WordPress registration and contact form 7 [closed]
- Add class to input form in login form
- Register a new user on wooCommerce using Rest API
- Creating user without username and password
- Display message on homepage when new user account is activated
- Check for valid email after user inactivity?
- Restrict partially matching usernames
- How to find the Registration page
- redirect doesn’t work while using example code
- Alert Message through email or phone(Message)
- I need a custom Login Registeration in WordPress can somebody guide me?
- how to change the register process
- Modify new user welcome email
- Meta data being pulled from wp-login.php
- Searchable Semi Random Number Generator on User Profiles
- Unable to Add User after Site Migration
- Profiling user with categories
- Problem in register activation hook and Copying folder
- Buddypress registration page hangs [closed]
- view and update form only for registered users
- How to force login after user browses for a few minutes or browses a few pages?
- Use WordPress engine for user registration and management