[Support request] How to Change the “Password Protected Page”?

Home Forums Support [Support request] How to Change the “Password Protected Page”?

Home Forums Support How to Change the “Password Protected Page”?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1994661
    Adam

    Hi, I have some posts protected by a password. Now, when you scroll through a category or the main page where the password-protected post is, it reads:

    “This content is password protected. To view it please enter your password below:”

    Is it possible to change this text? I’d like to add more context to that message, for example how to get this password.

    When I tried to edit the password-protected post, I could only edit the message.

    Thank you

    #1994913
    David
    Staff
    Customer Support

    Hi there,

    not easily… WP provides the the_password_form filter which would allow you to modify the password protect form:

    https://developer.wordpress.org/reference/hooks/the_password_form/

    You could also create a Block Element to display additional content on the page:

    https://docs.generatepress.com/article/block-element-overview/

    Whilst your creating the block, check the browser URL to get the ID of the block element.

    The Display Rule Location you would leave empty then we can use a PHP Snippet to display it if the page is password protected:

    add_filter( 'generate_element_display', function( $display, $element_id ) {
        if ( 100 === $element_id && !empty($post->post_password) ) {
            $display = true;
        }
    
        return $display;
    }, 10, 2 );

    The 100 needs to be updated to the ID of the Block Element.

    #1995439
    Adam

    Thanks David,
    yeah, that doesn’t sound easy but at least now I know not trying to change it. Thanks for mentioning the blocks. I’ll figure out some workaround.

    #1995760
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.