You don’t need array to do this. The following code will be worked. You have to just add other username also inside if condition with or
operation.
if ('plugins.php' === $pagenow ||'update-core.php' === $pagenow ) {
// wp_safe_redirect( home_url() );
// Now check the current user
$user = wp_get_current_user();
if ( $user->user_login == 'Remo' || $user->user_login == 'Sam') {
wp_safe_redirect( admin_url() );
exit();
}
If you want to use array you can add users to array and then you can use in_array
function to check it.
if ('plugins.php' === $pagenow ||'update-core.php' === $pagenow ) {
// wp_safe_redirect( home_url() );
// Now check the current user
$user = wp_get_current_user();
$users = array("Remo", "Sam");
if ( in_array($user->user_login, $users)) {
wp_safe_redirect( admin_url() );
exit();
}
Related Posts:
- How do I redirect upon login a specific user based on role?
- create shortcode to list users with specific meta key value
- Execute a ultimate member action when user role is updated
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- Get users with different roles and call function on each of them (user_meta)
- How can I show different content for different user-levels?
- Custom user role still showing up after deletion, ideas?
- Add Change role button for list of user in an event
- Making an under maintenance page (without using plugins)
- How to check if a user exists by a given id
- Use author author display name in permalink structure for pages and posts
- How to paginate the get_users function?
- PHP – redirect https to http and www to non-www
- How to display random users with avatars
- Masking logout URL
- Apply custom role capabilities to administrator (without plugin)
- Logout/login redirect CSS issue
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- wp_delete_user with username
- redirect wp-login.php to another page
- Change labels on ‘Nickname’ and ‘Biographical Info’ in user-edit.php
- how to get and display logged in user’s recently read posts
- How to update BuddyPress xprofile fields programmatically? [closed]
- Redirect if not logged in?
- How to detect first visit of a user?
- How to add another user to this remove_menu function?
- Redirect after login based on user role (custom login page)
- Add a new subscriber role using a function
- wordpress custom login successful redirect hook
- Can I pass two roles to the function get_users?
- How can I add an image field to BuddyPress Extended Profile Fields? [closed]
- Create dropdown of users in admin dashboard
- Custom roles can’t access to wp-admin
- Redirect a list of URLs to another URL, using functions.php
- Redirect after users complete profile form
- password protected post policy
- is_user_logged_in not working to redirect only logged out users
- Remove the deleted users avatar from list
- Hide Author.php template from specific user role
- edit role display name and label name without plugins
- Ninja form Redirect depending on text field content [closed]
- How to add custom fields to my custom registration form
- How do I redirect all 404 error url to Subcategory url
- Php function 301 redirect
- Don’t delete a page if it holds users
- Toggle User Roles with button
- How to change or add user role after getting post request data about pay? [closed]
- How to make custom column Admin>Users sortable?
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- Redirect 404 page with ID in slug to associated page with same ID in slug
- Force to use STRONG users password and implement rule to prevent REUSE [closed]
- Login Redirect if Logged in from Specific Page
- Change label for registration Fields
- Using wp_redirect and .htaccess to re-route searches (and pass along the remaining GET vars)
- Cannot modify header information – headers already sent (wp_redirect in functions.php)
- Allow Contributor to edit their own posts after Adm aproval
- How to set default post editor based on role?
- How to Use Global Variables Inside Header and Footer
- Secondary Menu and Logged In Users
- load CSS only for administrators on backend
- Solved: redirect to another page using functions.php
- Logout Redirect and also WP-login.php Redirect
- Add Link to Users List (Backend) to open each users front-end profile
- WordPress website keeps loading the maintenance page
- Suggest Users basing on User taxonomy
- Showing user profile data on front-end
- Modify function to only return values for the user that’s logged in
- loginout function customization
- call wp_insert_user in custom class doesnt work
- Show errormessages on wrong username/password on custom loginform?
- referencing the current user in a page i created in wordpress
- Redirect Page ID, based on logged-in User Role
- How to redirect Subscribers on login to specific page, when logging in from a Page
- Allow a user or role to view drafts and previews, but not other admin privileges?
- How to load a css file depending on the current role
- Redirect to one of two pages after data submitted, depending on the current url
- Deleting guests profile users after 1.5 hours
- wp_get_current_user return ID = 0 when used outside of wordpress, such as webhook / fulfillment dialogflow
- get_current_user_id() always return 0 in if else statement
- How to show only specific category post by user role without plugin and restrict all other cats
- Competing Login Redirects – Need to be Combined?
- Postback redirect through add_action is not triggered
- Redirect /member/ to /member/user
- Add another role to a user when they click a button?
- Change user role based on total number of items ordered
- Redirect specific author posts to another url
- Remove all video attachment, both files and post/postmeta from database?
- delete_user_meta for user in spesific group
- Custom download page
- Change the second role depending on the first
- Restrict certain roles registrations by domain
- How to create a function to redirect a specified page to another page
- Multisite Admin Roles
- Language switcher for subdomains
- add_role menu pages are not visible
- Allow the access over wp-login.php
- How to request login for user but not for bots
- Whats the proper way to add a new user via a front end form?
- Get all users from role and add to dropdown (select) – wordpress, javascript
- Custom Admin Menu Report for Specific User ID