Skip to content

Instantly share code, notes, and snippets.

@mattiasghodsian
Last active April 28, 2023 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattiasghodsian/21ab3ce7773eab1c4c0ca50fd5b43675 to your computer and use it in GitHub Desktop.
Save mattiasghodsian/21ab3ce7773eab1c4c0ca50fd5b43675 to your computer and use it in GitHub Desktop.
[Wordpress] Fix Password Protect pages with Elementor
/**
* Fix Password Protect pages with Elementor
*
* Author: Mattias Ghodsian
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*
* @param string $content
* @return html
*/
add_action( 'elementor/frontend/the_content', function( $content ) {
GLOBAL $post;
if ( strpos($content, 'elementor-location-single') !== false && post_password_required( $post ) )
return '<div class="content-protected">'.get_the_password_form().'</div>';
return $content;
});
@jeanlorencini
Copy link

i love you for that

@mattiasghodsian
Copy link
Author

i love you for that

You're welcome

@abchiaravalle
Copy link

I also love you so much, do you have another way to send you a coffee? My paypal is super derped

@mattiasghodsian
Copy link
Author

I also love you so much, do you have another way to send you a coffee? My paypal is super derped

You'r welcome, I have updated the snippets donate link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment