• Resolved Eric Schmid

    (@schm1eric)


    I found this thread, which gets some of my issue addressed.
    https://ww.wp.xz.cn/support/topic/function-in-3-1-8-ps_conditionalis_password_valid/

    I have a page template and I want to password protect on the template. I have set this the following below. I see the password form, but when I enter in the password of 123, I get told ‘invalid password’. Am I missing something?

    <?php

    $args = array( 'password' => 123 );
    
    if ( passster\PS_Conditional::is_valid( $args ) ) {
    
    while ( have_posts() ): the_post();
    
    the_content();
    
    endwhile;
    
    } else {  // If not logged in, show the Login Form
     ob_start();
     the_content();
     $content = ob_get_clean();
     $shortcode = '[passster password="123"]' . $content . '[/passster]';
     echo do_shortcode( $shortcode );
     }
    
    // End Password Protection

    ?>

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hey @schm1eric,

    thanks for your message.

    The is_valid() method works slightly differently now.

    Take a look at wp-content/plugins/content-protector/src/class-ps-conditional.php.
    You can also find a working example in wp-content/plugins/content-protector/src/class-ps-public.php, search for the method “filter_the_content”.

    Basically, you add the content now in that function and Passster handles the rest (returns the content or the result of the shortcode).

    Best regards,
    Patrick

Viewing 1 replies (of 1 total)

The topic ‘Password on a template’ is closed to new replies.