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

current_user_can(‘administrator’) not working in custom login

the current user may not be set at this step then try this :

    if (user_can($user, 'administrator'))
    {
        wp_redirect($admin_url);
    }

Related Posts:

  1. How can I restore admin capabilities?
  2. What determines whether admin toolbar is shown to a logged-in user?
  3. How do you set up a WordPress blog with multiple authors to allow something like StackExchange’s “community wiki” feature?
  4. WordPress Remove Submenus
  5. Redirect admin 403 “Cheatin uh?” admin pages
  6. How can I create multiple different admin roles with their own capabilities
  7. How do I remove dashboard access from specific user roles?
  8. How to Change the Default Home Page for the WordPress Dashboard?
  9. Prevent author from changing their posts if admin has modified
  10. Cannot access admin panel
  11. Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
  12. How to remove administrator role in settings -> general -> New User Default Role?
  13. Create un-removeable user
  14. Read only capability for custom post in admin area
  15. Custom CSS In Admin Only For Certain Roles
  16. Remove ability to access certain admin menus
  17. Remove admin AND editor from the “change role to” menu in user listing
  18. Role that can edit only widgets, not other theme options
  19. Daily notices of failed login attempts for non-existent admin user
  20. How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
  21. Customize the upload screen
  22. Blocking Administrative Access to Authors and Subcribers?
  23. Customize Admin Users Screen based on Role
  24. Make certain pages uneditable by editors?
  25. Setting Login with User Name and Password default option for Jetpack Admin Login
  26. I keep getting logged out in Firefox
  27. Restrict dashboard access for specific user roles to specific actions
  28. Error thrown. Cannot create references to/from string offsets
  29. How to determine if an admin is logged in outside the loop
  30. Unable to login, old site with previous developer gone
  31. Using shared SSL for login/admin
  32. Logout users upon login, based on caps/role?
  33. wp-login behind nginx reverse-proxy inaccessible — bad redirect?
  34. Can’t access dashboard as administrator, login as any other level works though
  35. Admin cannot publish
  36. WordPress Admin Login Redirect Problem
  37. Unable to Access WP Admin or Login buttons after Migration
  38. using rewrites to secure login page
  39. Client system for media review?
  40. WordPress administration Over SSL – To Force SSL Logins and SSL Admin Access
  41. Keep Logged in Users out of Admin Panel
  42. Unable to get to the admin panel
  43. Only Admin can Edit, Delete or Update
  44. add_cap for editor but no admin role
  45. I can’t access the login panel on my offline website
  46. Shared account / dual blogging in WordPress
  47. Bind custom role to admin page
  48. Admin login not working
  49. remove menus for a specific role?
  50. Can’t login to my admin area
  51. Does deleting the table users prevent all logins?
  52. Locked out of WordPress website from wrong amount of login attempts
  53. Show global Message in User Profiles with admin only Input field in WordPress Backend
  54. How to make sure your admin doesn’t hi-jack you site?
  55. Send admin to a different login than users?
  56. Remove specific administrator’s capability
  57. Given multiple admin accounts, how can I make it so that only admin with X username can edit posts
  58. How should I setup the “Users” area to hand over to a client?
  59. solution to prevent specific admins from altering site contents
  60. Admin user roles/permissions
  61. “sufficient permissions” error for admin after duplicating WP database to new install
  62. Posts in sidebar only by admin
  63. Want to know who is login Admin/User
  64. How to hide plugin options for editors via functions.php
  65. Remove iPhone detection on login page
  66. Any known plugins for master admin login to edit all on front end?
  67. Give admin_menu permission to specific users
  68. Login to admin by frontend form?
  69. Error “Sorry, you are not allowed to access this page”
  70. I can’t access login page
  71. Cannot access wp-admin after installing SSL – user capabilities not being set
  72. Redirect non-admin after login, and in url – /admin
  73. Hide top admin panel for non admin and non editors
  74. Admins loggin in to our wordpress site default to the admin page
  75. Different role for free and pro users in wordpress without using bbpress
  76. WordPress login not working
  77. Login to Admin Dashboard Problem
  78. WordPress login process is hanging
  79. WordPress “Hide WP” Gives Me Error After Admin Login [closed]
  80. Scripts are not called until I login from wordpress backend
  81. Disable wp-admin log on lightbox overlay
  82. Capability to read/edit page in wp-admin only for administrators
  83. How to cancel redirection to admin side
  84. I don’t have permission to save the theme options I created myself?
  85. Can’t access my wp admin: captcha images invisible, gives me error message
  86. Different customer login form than administrator login form?
  87. 2FA for admin login only, is it doable?
  88. What are the standard admin CSS id/class tags?
  89. Getting a List of Currently Available Roles on a WordPress Site?
  90. Editor can create any new user except administrator
  91. Admin Ajax is returning 0
  92. Add custom column to Users admin panel
  93. Is there way to rename user role name without plugin?
  94. How to create a clone role in wordpress
  95. wp_verify_nonce vs check_admin_referer
  96. Add a Separator to the Admin Menu?
  97. How to determine whether we are in add New page/post/CPT or in edit page/post/CPT in wordpress admin?
  98. Possible to hide Custom Post Type UI/Menu from specific User Roles?
  99. how to know if admin is in edit page or post [duplicate]
  100. Modal window from within WordPress admin
Categories admin Tags admin, capabilities, login, user-roles
How to pass variables from one function to another or combine functions
Add category into post permalink

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