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

Redirect non-admin after login, and in url – /admin

All functions place in functions.php of your theme. And create redirect on template_redirect hook.

add_action('template_redirect', 'make_redirect');
function make_redirect() {
    if ( ! is_admin() && ! current_user_can( 'administrator' ) ) {
        wp_redirect( 'https://google.com' );
    }
}

Related Posts:

  1. Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
  2. How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
  3. Restrict dashboard access for specific user roles to specific actions
  4. Redirect admin 403 “Cheatin uh?” admin pages
  5. You do not have permission to access this document on form submit
  6. Different customer login form than administrator login form?
  7. How do I remove dashboard access from specific user roles?
  8. The website cannot display the page
  9. Can an admin check passwords of registered users?
  10. Prevent author from changing their posts if admin has modified
  11. How to remove administrator role in settings -> general -> New User Default Role?
  12. Create un-removeable user
  13. Custom CSS In Admin Only For Certain Roles
  14. Remove ability to access certain admin menus
  15. Remove admin AND editor from the “change role to” menu in user listing
  16. Customize the upload screen
  17. Blocking Administrative Access to Authors and Subcribers?
  18. Customize Admin Users Screen based on Role
  19. Make certain pages uneditable by editors?
  20. How to display only logged in user’s post comments in comments area
  21. Check if user is logged in else login page
  22. How can I restore admin capabilities?
  23. Protect custom php file with login
  24. What determines whether admin toolbar is shown to a logged-in user?
  25. front end editing using iFrames, best approach?
  26. How do you set up a WordPress blog with multiple authors to allow something like StackExchange’s “community wiki” feature?
  27. Displaying different in-page content to cliente/admin
  28. How to hide a specific part of dashboard for non-admin roles?
  29. WordPress administrator area access disabled temporarily due to widespread brute force attacks
  30. WordPress Remove Submenus
  31. Create a WordPress administrator without access to back-end
  32. Only Admin can Edit, Delete or Update
  33. add_cap for editor but no admin role
  34. Shared account / dual blogging in WordPress
  35. Bind custom role to admin page
  36. Admin login not working
  37. Access for adding subpages but not for pages
  38. remove menus for a specific role?
  39. Hide front-end from every logged out user and redirect them to the default login page
  40. Allow admins to login as other users
  41. current_user_can(‘administrator’) not working in custom login
  42. Show global Message in User Profiles with admin only Input field in WordPress Backend
  43. How to make sure your admin doesn’t hi-jack you site?
  44. Send admin to a different login than users?
  45. Given multiple admin accounts, how can I make it so that only admin with X username can edit posts
  46. How should I setup the “Users” area to hand over to a client?
  47. solution to prevent specific admins from altering site contents
  48. Admin user roles/permissions
  49. Posts in sidebar only by admin
  50. Custom user roles are unable to login
  51. How To Remove Import/Export Option From Tools?
  52. Doesn’t call user information to include “wp-load.php” in an external php file
  53. Hide top admin panel for non admin and non editors
  54. How can I create multiple different admin roles with their own capabilities
  55. Signed-in as admin on just part of the site
  56. How to change the title attribute for the WP logo image on wp-login.php
  57. Different role for free and pro users in wordpress without using bbpress
  58. WordPress login process is hanging
  59. Capability to read/edit page in wp-admin only for administrators
  60. Add custom column to Users admin panel
  61. Sort pages in loop by admin’s page attributes order field?
  62. Edit “thank you for creating with WordPress” in version 3.3.1
  63. Plugin to remove Admin menu items based on user role?
  64. How to obtain the user ID of the current profile being edited in WP-Admin?
  65. Disallowing Users of a Custom Role from Deleting or Adding Administrators?
  66. Hide Admin Menu for Specific User ID who has administrator Role
  67. Get current active wp color scheme
  68. How to fix admin stylesheet muck-up? [closed]
  69. Turn off admin emails for new user registrations
  70. Adding custom Javascript to the head tag in Admin
  71. Replacing the List table of a Post Type
  72. Adding scripts to admin page in my theme
  73. How to notify the admin about something that happened during a cron job
  74. I’m receiving requests to change the admin email. How can this be happening?
  75. Set admin body to ltr on a rtl installation
  76. Are there any filters to add additional columns to the list table on edit-comments.php?
  77. Can I mass change all admin emails for a multisite instance?
  78. WordPress admin area used to administer other site
  79. How to create user specific pages (not user role!)?
  80. Add ‘Last Modified’ and Attachments (Yes/No) to WordPress Users Column
  81. Seems that admin_post_{action} does not executing
  82. How to log out from admin or front-end only?
  83. remove wp admin menu by customer user role
  84. WordPress Brute Force Prevention
  85. admin_enqueue_scripts not rending JS file correctly
  86. Accidentally changed website url
  87. Private post hidden from Admin too
  88. Having problem creating local instance of wordpress site
  89. WordPress Plugin Admin Tab
  90. Give users acces to admin a single post or set up WP network?
  91. if role is logged in then do something
  92. Gutenberg UI has changed
  93. Highlight active Admin Menu when added though add_menu_page
  94. When admin approves a registered user, I don’t want to send a notification email to users
  95. add instructions to upload pages and / or forms
  96. Populate Dropdwon with DIR files, save value and keep it “selected”
  97. Blank page beyond dashboard
  98. Cannot save Post
  99. each user having category with their name and can add sub categories post in that category
  100. I don’t have permission to save the theme options I created myself?
Categories admin Tags admin, user-access, user-roles, wp-login-form
WordPress Admin sub-level menu issue
Ajax Response Error | just getting error as the response

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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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