- This topic has 5 replies, 2 voices, and was last updated 5 months, 3 weeks ago by
David.
-
AuthorPosts
-
October 7, 2022 at 5:38 am #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?
ThanksOctober 7, 2022 at 6:57 am #2366213David
StaffCustomer SupportHi 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
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 7, 2022 at 7:23 am #2366227anabella
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!October 8, 2022 at 5:24 am #2366967David
StaffCustomer Support1. correct
2402
is the ID.
What Hook did you select ?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 9, 2022 at 12:50 am #2367511anabella
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.
October 9, 2022 at 5:18 am #2367647David
StaffCustomer SupportOk, 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.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.