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)
- Admin Page Redirect
- Adding fields to the “Add New User” screen in the dashboard
- How to check if a user exists by a given id
- Use author author display name in permalink structure for pages and posts
- Get a list of all available fields in the User Profile
- Logout redirect to current page – function
- 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
- How to manually activate user in dashboard only by admin
- Apply custom role capabilities to administrator (without plugin)
- Add new user : make the fields First Name and Last name required
- Logout/login redirect CSS issue
- Roles & capabilities GUI that does not create separate table
- 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
- Order get_users() by last login date. Is it possible?
- How can I tell when a user is logged in?
- how to get and display logged in user’s recently read posts
- Displaying a random user with a shortcode
- 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]
- How to test for Super Admin
- 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
- Custom registration URL lost when user makes signup mistake
- Custom function for specific user role
- 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
- Get Current User info using wp_localize_script, in functions.php
- Ninja form Redirect depending on text field content [closed]
- How to add custom fields to my custom registration form
- Redirect specific page in WordPress for first time visit
- 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
- 404 redirect to previous category
- 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
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Allowing users to view private posts (pending approval)
- Using wp_redirect and .htaccess to re-route searches (and pass along the remaining GET vars)
- Incorrect redirect after commenting
- Cannot modify header information – headers already sent (wp_redirect in functions.php)
- Allow Contributor to edit their own posts after Adm aproval
- How to add custom JavaScript in functions?
- Condition OR for current user ID
- How to set default post editor based on role?
- How i can put $_GET codes in function.php?
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- How to Use Global Variables Inside Header and Footer
- Page get parameter doesn’t work with is_single() function
- Secondary Menu and Logged In Users
- Why get_user_by() doesn’t work in my code?
- load CSS only for administrators on backend
- Adding additional roles on registration
- Filter to wp_list_authors
- Contact Form 7 If Condition
- Solved: redirect to another page using functions.php
- Redirect to other page if login
- The Capability to choose post/page template
- 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
- Remove attachment page for audio media type only
- Redirects based on a JSON file
- 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