Advertisement
arie_cristianD

prevent contributors from accessing the WordPress admin area

Jun 10th, 2025
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. add_action(
  2. 'admin_init',
  3. function () {
  4. if ( current_user_can( 'contributor' ) && ! defined( 'DOING_AJAX' ) ) {
  5. wp_redirect( home_url() );
  6. exit;
  7. }
  8. }
  9. );
  10.  
  11.  
  12. add_filter(
  13. 'show_admin_bar',
  14. function ( $show ) {
  15. if ( current_user_can( 'contributor' ) ) {
  16. return false;
  17. }
  18. return $show;
  19. }
  20. );
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement