Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Disable site visiting and user logins excepting for a specific user

Your if case matches any user who is not both a super admin and test_user.

For example, given a user test_user who is not superadmin, the result would be

if (true || false) redirect

Since one condition is true, the redirect would be triggered. Using the && operator, you’d get

if (true && false) redirect.

Since both are not true, it doesn’t trigger the redirect.

Related Posts:

  1. Good way to block users within a multisite setup without deleting them?
  2. Some Subdomains on a Multisite Install Not Found
  3. Is there a is_user_logged_in() for multisite?
  4. Troubleshooting a “You do not have sufficient permissions to access this page” error
  5. Restrict users on multisite WordPress install
  6. Unable to login to new custom domain on multisite?
  7. share login/logout sessions across two installs?
  8. How to Login Once to an Entire WP Multisite Network
  9. Can you have multi-site WP and keep users separate?
  10. Multisite – Redirect All Users to Subsite Home Page on Subsite Login
  11. Restrict the user access in multi site for non-assigned blogs
  12. WordPress Multisite Login Access
  13. Multisite Independent User Base
  14. How can I get multisite primary blog (url or path) for current user?
  15. Subdomain login problems
  16. WordPress Multisite local: wp-login.php refreshes on login Chrome Browser
  17. ‘Remote Login’ with MultiSite Domain Mapping still forcing users to login to all blogs individually?
  18. How to stay logged in on a multisite with different domains?
  19. WordPress Multisite prevent direct access to subdomain
  20. Login on Multiple Sub-Domains without Multisite
  21. Fresh Multisite Install – Can’t Log In
  22. Auto Redirect after login
  23. access the plugins for each role in WordPress multisite
  24. WordPress MultiSite login to the respective site
  25. How to protect post attachments related to a custom post type, from non-logged in users, on 1 subsite of a multisite installation?
  26. Multisite registration problem [closed]
  27. How to fix blocked cookies error that doesn’t let me log into wp-admin?
  28. Subsite access without being a member of the subsite in wp multisite network
  29. Automatically login user across multisite
  30. How can you override the is_multisite check in wp-login.php for individual login/registration?
  31. How to write RewriteRule for login in multisite
  32. Multi-Site Subfolder User Permission Issue
  33. Add access control origin header information across multisite
  34. One Site as a part of Multisite to be hidden (Un-published) from Public?
  35. Multisite Login problem
  36. Https and Http Login Issue on WordPress Multisite
  37. Different Domains in Multisite Setup
  38. Multisite infinite redirect loop
  39. Hiding media uploaded by other users in wordpress multisite?
  40. Infamous admin login redirect
  41. Common user login for two different wordpress installation and bbpress
  42. How to check main site user level from subsite in a multisite network
  43. Give users acces to admin a single post or set up WP network?
  44. Is there something I need to know in order to use WordPress on foreign (Swedish) TLDs?
  45. Restrict users of site 1 to login in site 2 in wordpress multisite
  46. Unable to execute Ajax request, status code 400
  47. How to display custom logo on WordPress login page
  48. Moving from a non WordPress site to a WordPress Site – Login between both sites
  49. WordPress Multisite: Login to all subsites at once
  50. Users getting linked unwanted to main mu in WordPress multisite (WPMU)
  51. Multisite – site user limited only for this site
  52. Unable to sign in to network after moveing address but able to login into child sites
  53. User not staying logged into one of sub sites in multisite after SSL
  54. Single sign on to sub-sites in Multisite Network
  55. WordPress automatic Login on other page?
  56. how to make a cronjob run, when user needs to be logged in
  57. WordPress Network with SSL for multiple domains
  58. Why does this multisite redirection loop vanish when I add “www.”?
  59. WordPress Multisite FQDN Admin Access
  60. One login for 3 WordPress installations with combined user table doesn’t work
  61. Multisite: Redirect Subsite Administrator to Subsite Home Page, Bypassing Dashboard
  62. Admin user getting redirected to /wp-admin/user
  63. How to login a user with wp_set_auth_cookie on a specific blog within a multisite environment
  64. Is it possible to create a login for restricted visibility?
  65. How do I combine wp_redirect and add_filter?
  66. Common login for websites belonging in different networks
  67. Best Way to Setup a Network of WP Sites?
  68. WordPress Multisite restict user access
  69. Error Message when logging into WordPress on Xampp
  70. Multisite Login Access Restrictions
  71. WordPress MU: Cookie error when trying to login on network WP instance
  72. something in database is causing me to not be able to log into network admin of multisite
  73. Weird Issue – WordPress Multisite – Cannot Access subdomain’s pages
  74. Why am I getting the login screen in wp-admin->Appearance->Customize?
  75. Keep users logged in across multisite in wordpress (for various domains)
  76. How to use WordPress Multisite With Different Domain Names?
  77. How To Add Custom Form Fields To The User Profile Page?
  78. How do I create a custom role capability?
  79. Where are available Roles Defined in the wp_ database?
  80. restore_current_blog() vs switch_to_blog()
  81. Can i merge 2 new WP_Query($variable) ‘s?
  82. How to disable a network enabled plugin for just one site?
  83. How to reliably flush rewrite rules on multisite?
  84. Site Redirecting to wp-signup.php
  85. Moving a WP Multisite to a subdirectory
  86. Cookies in multisite where network sites have their own domain name
  87. Convert a Multisite WordPress install into a Single site
  88. WordPress MultiSite Active Directory integration and site privacy
  89. WordPress Job Interview Preparation
  90. How to add Custom Blog Options to new blog setup form?
  91. How can I trust switch_to_blog()?
  92. Remove the blog slug from WordPress Multisite root node
  93. Why are my roles not visible in a Multi-site/Network?
  94. Site admin in a network install can’t edit users?
  95. How to use same email for multiple users
  96. How to run an activation function when plugin is network activated on multisite?
  97. Specific upload folder for PDFs in custom Post type in WP multisite
  98. What is the correct way to map multiple domains in a WordPress 4.1 multisite install?
  99. Where can I find documentation on what characters are allowed in user names and why?
  100. How to migrate subsite from dev multisite to production multisite
Categories multisite Tags login, multisite, user-access
Outputting HTML elements through WP-API
Get posts with no tags?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress