0

Even after I removed the code, I am still getting the error message "Sorry, you are not allowed to access this page." please help me to fix this

function remove_read_wpse_93843(){  
    $role = get_role( 'subscriber' );
    $role->remove_cap( 'read' );    
}
add_action( 'admin_init', 'remove_read_wpse_93843' );

1 Answer 1

0
function add_read_wpse_93843(){
  $role = get_role( 'subscriber' ); 
  $role->add_cap( 'read' );
} 
add_action( 'admin_init', 'add_read_wpse_93843' );

This code is work for me

2
  • Yes that's right: remove_cap() removes the role from the database and add_cap() puts it back. Note that you only need to run this once: you can remove this code again, although it's possibly OK to leave as it won't do extra database writes if the role already has the capability.
    – Rup
    Aug 27, 2023 at 20:45
  • Thanks for the reply, Can you help me redirect to another page?
    – Roma VV
    Aug 28, 2023 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.