[Support request] How to change text in password protected page

Home Forums Support [Support request] How to change text in password protected page

Home Forums Support How to change text in password protected page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2366156
    anabella

    Hi. On the password protected page, I need to change the text: instead of having the default “this content is password protected. To view it please enter the password below”, I need it to say “send me an email at example@myemail.com and I will give you the password”

    Is there an easy way of achieving that?
    Thanks

    #2366213
    David
    Staff
    Customer Support

    Hi there,

    see my reply here:

    https://generatepress.com/forums/topic/how-to-change-the-password-protected-page/#post-1994913

    I would suggest trying the Block Element method to insert your custom message. Let me know

    #2366227
    anabella

    Thanks David.
    I am trying the Block Element method but it’s not working.

    1. I created the block by going to Elements > Create new > Block > I added my content. Then > location: I left that empty > Element type: Hook. The URL looks like this: /post.php?post=2402&action=edit&lang=es
    I am assuming that 2402 is the ID of the block element?

    2. The I added your code using the plugin Code Snippets:
    add_filter( ‘generate_element_display’, function( $display, $element_id ) {
    if ( 2402 === $element_id && !empty($post->post_password) ) {
    $display = true;
    }

    return $display;
    }, 10, 2 );

    Could you please let me know what I’m doing wrong?
    Thanks!

    #2366967
    David
    Staff
    Customer Support

    1. correct 2402 is the ID.
    What Hook did you select ?

    #2367511
    anabella

    In the HOOK NAME drop-down, I tried all the options that are in the CONTENT section (so, inside_site_container, site_container, before_main_content, etc). Unfortunately none of them worked.

    #2367647
    David
    Staff
    Customer Support

    Ok, so change the Element Type to: Page Hero
    And set the Display Rules to All Posts and All Pages ( or wherever you’re using password protects ).
    Then change the snippet to:

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

    That way the element is set to show everywhere, and snippet will remove it if there is NO password on the post.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.