We can check the $request
which is passed to our login_redirect
filter-function using url_to_postid.
// redirect subscribers if logging in from specific page
function wpse381872_login_redirect( $redirect_to, $request, $user ) {
// turn the request url into a post-id
$request_id = url_to_postid( $request );
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
// check for subscribers logging in via 1865
if ( 1865 === request_id && in_array( 'subscriber', $user->roles ) ) {
$redirect_to = 'http://destredirectedpage.php';
}
}
return $redirect_to;
}
add_filter( 'login_redirect', 'wpse381872_login_redirect', 10, 3 );
Related Posts:
- Redirect after User Activation [closed]
- Redirecting user after updating profile?
- Redirect User to Homepage if no other redirect is specified
- Redirect after users complete profile form
- Rule to redirect non logged in User to Custom Registration/login Page in .htaccess file
- Redirect user to login before viewing custom post
- Redirect subscribers to last viewed page after log-in
- Redirect user after successful email change
- WP_User_List -> How to open a new edit-page in WordPress admin backend!
- How to stop redirect if user is already on correct page (Using Case Switch)
- WP not logging in at first time
- How to check User Role and redirect to specific page according to Role when login in WordPress?
- How can I do a url redirect to include a wordpress username?
- Redirect users after login
- Redirect user to login if not logged in, on specific pages
- redirect user to their profile after log in
- WordPress Redirect Specific User. Tired of Peter’s redirect Plugin its not working
- Redirect current user to their most recent custom post
- how redirect users to custom login page when “login to reply” is clicked? [duplicate]
- How to remember which page the user was on before logout?
- Redirect /member/ to /member/user
- Specific Content on pages based on user
- Redirect current user
- Redirect based on log-in status per JavaScript
- Redirect user based on role when they try access a particular page
- Editor can create any new user except administrator
- Confirmation required on email change
- get_current_user_id() returns 0?
- List users by last name in WP_User_Query
- Email user when password is reset by admin
- How to work around “that email address has already been used” error?
- How to redirect a specific user after log-in?
- How to Prevent deleting user accounts in WordPress Back-end?
- Upload gravatar in WP profile?
- How to stop a user from updating the post date
- determining if the user is logged in
- Adding a photo to each WP user
- WordPress edit_user_profile_update update secondary role
- Check if user is online?
- set_role has no effect
- Is it possible to duplicate users on a new WordPress install?
- How to use search_columns in WP_User_Query?
- Get users only if Gravatar is specified
- WordPress to use Drupal users’ credentials
- Authenticate with a Rails app?
- How do I list in the backend all users that were assigned to a custom role?
- How to add local users to wordpress without email password?
- Suddenly all emails in User have [email protected]
- Updating user meta
- Are User Levels Still Currently Used?
- How to add a user profile page to frontend?
- Where is the information about the authors for articles stored?
- Using Cloudflare caching on wordpress with front-end user logins
- get_user_meta an ID for multiple functions
- Reset Password policy
- Which function is called after update any field of user from any where of the site
- Register user when after filling contact form
- Is possible to allow user to login with different role?
- The Simple and Correct Way to Add User Meta
- Export Users and their Advanced Custom Fields
- Hide hour from displaying when using user_registered
- Allow unfiltered HTML for not logged in users when saving a post
- How to copy user_nicename value into user_login
- Users – remove ‘send password’ checkbox
- Send email to all registered users [closed]
- WordPress current month users
- I’ve removed my /author/ slug but it clashes with new and existing pages. Any fixes?
- Allow Users to Modify Some Values of Assigned WordPress Pods [closed]
- Make new users automatically approved
- Admin approval for editing user profile
- Using a custom field value as current users name [closed]
- What does “link” refer to when you delete a user?
- WP Create User – Preventing repeated information
- Editor role can only create/edit/delete users who have one of two roles
- Can’t add user- wrong message “this user name is invalid because it uses illegal characters”
- set automatically email address for WordPress users
- WordPress 5.8 – Hide or Remove personal fields from admin Profile page
- hide user is currently editing warning in admin post page
- Use WP cookie to authentificate user on an external app
- How do I add profile fields in specific section?
- fine-grained capabilities for user related capabilities
- Custom User Role: Can Edit Own Page, Cannot Create New
- How to restrict Admin from creating new users from Add new user screen in dashboard to only of one domain?
- Get meta key with value for user
- Display Users and user url’s
- custom login form, guide me
- Edit dashboard based on user ID
- is_user_logged_in() not working after domain change
- Get the author registration date in the header.php file
- Front end login and page restriction
- How i will get the images of highest scored users?
- Designing a member area on my site
- Redirect authors from upload.php url to Home page in Multisite
- Integrating Facebook Registration (and Login) on a WordPress page
- WordPress C# User Login
- Why does a super admin on multi site get a rest_user_invalid_id error code when requesting user details through REST?
- Remove @gmail.com from WordPress username
- How to create a specific role to manage users
- How to track all users logged into a site?
- Export user data from Squirrly’s Starbox plugin?