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. Administrator user cannot access dashboard after localwp import
  61. What are the standard admin CSS id/class tags?
  62. Admin Ajax is returning 0
  63. Add custom column to Users admin panel
  64. Allow member to have access to custom post type only. Permission to only edit their own posts
  65. wp_verify_nonce vs check_admin_referer
  66. Add a Separator to the Admin Menu?
  67. How to determine whether we are in add New page/post/CPT or in edit page/post/CPT in wordpress admin?
  68. how to know if admin is in edit page or post [duplicate]
  69. Modal window from within WordPress admin
  70. Where in WP can I check history or log of updates of plugins etc?
  71. Adding a custom admin page
  72. How does admin-ajax.php work?
  73. How to check if user is in back end?
  74. Remove update nags for non-admins [duplicate]
  75. Give Editor Access To Sidebar
  76. How to remove entire admin menu?
  77. How can I speed up my WP admin section?
  78. How to pass parameters to admin_notices?
  79. Admin: very slow edit page caused by core meta query
  80. if admin is logged in
  81. Search posts by ID in admin
  82. How to Change the Default Home Page for the WordPress Dashboard?
  83. Setting admin edit panels & metaboxes positions and visibility for ALL users and admins
  84. Find out which moderator approved comment?
  85. How To Remove WordPress Version From The Admin Footer
  86. Sort pages in loop by admin’s page attributes order field?
  87. Edit “thank you for creating with WordPress” in version 3.3.1
  88. Hide other users’ posts in admin panel
  89. Set Default Admin Colour For All Users
  90. Editor Styles and Typekit
  91. WordPress admin stylesheet
  92. This CSS Stuffing Works, But Is This A Good Practice?
  93. Is it possible to create a WordPress tour? V3.3.1
  94. Securing Admin Accounts – Username Discovery
  95. is_admin() returns true when using admin-ajax.php from front end script
  96. wp_update_user not updating
  97. How to save dismissable notice state in WP 4.2?
  98. How do I optimize a custom post type admin page with 25,000 posts?
  99. Settings API – adding setting fields dynamically?
  100. Disable Media Uploads to non Admin Users
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
  • 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