Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1292374

    Hello
    Is there an option to let the administrator access all password protected pages without having to enter a password ?

    I am an admin, and i have password protected pages that i require my users to enter a password in order to check the content. But everytime i try to access these pages while i am logged in as admin, it asks me for the password as well

    This is not logical since i am the creator and owner of the page/website

    How can i bypass all passwords for pages and posts ?
    Thanks

    #1292438

    i found this with a filter to bypass password .
    in child-theme functions.php:

    add_filter( 'post_password_required', 'remove_password_requirement_for_admins', 0 );
    function remove_password_requirement_for_admins( $required ) {
        if ( current_user_can( 'manage_options' ) ) {
            $required = false;
        }
        return $required;
    }

    maybe this will work for admins:

    
    add_filter( 'post_password_required', 'remove_password_requirement_for_admins', 0 );
    function remove_password_requirement_for_admins( $required ) {
        if ( current_user_can( 'administrator' ) ) {
            $required = false;
        }
        return $required;
    }

    you can see here some infos about options in a table : https://wordpress.org/support/article/roles-and-capabilities/#capability-vs-role-table
    because manage_options is only for admins allowed the above should work too.

    #1292501

    @Guenni007
    THANK YOU SO MUCH ! this saved a lot of my time thanks to your code .. so far it is working good
    I only used the second code
    I don’t really know what manage-options is ! i only need to bypass password on the blog posts and pages

    Many thanks again

    #1292623

    thats why i link to the list above.
    the capabilities are correlated to the roles.
    only super admins ( only on multi-site installation) and admins are able to manage options:

    #1292758

    Thanks again :)

    #1293158

    Hi @Cloudypro,

    Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

    #1293233

    Yes it is solved
    Thanks you all

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘ADMIN BYPASS PASSWORDS’ is closed to new replies.