How to Password Protect Elementor Templates with PPWP Pro

By default, our Password Protect WordPress (PPWP) Pro only protects the normal post’s content and excerpt. That’s why it doesn’t work on your custom templates. Here’s how to password protect Elementor Template with our PPWP Pro.

Once you have everything set up with Elementor Pro, simply put the code below at the end of your (child) theme functions.php in order for the protection to work.

add_action('elementor/theme/before_do_single', 'ppwp_before_do_single', 16);
function ppwp_before_do_single( $slug ) {
    if ( post_password_required() ) {
        echo get_the_password_form();
        echo get_footer();
        exit();
    }
}

 

Lasted updated on May 13, 2020