• Resolved vkristic

    (@vkristic)


    Hi! If I try to put your shortcode [passster] in a template file like this:
    <?php echo do_shortcode('[passster password="0123456789"]'); ?>
    it won’t wrap any of content.

    My intention is to wrap a content in a template file like this:

    <?php echo do_shortcode('[passster password="0123456789"]'); ?>
    <article>My content ... end of content</article>
    <?php echo do_shortcode('[/passster]'); ?>

    However, [/passster] is not a shortcode for itself, so I would need a different closing shortcode, like [passsterclose] or something similar. Would that be possible anyhow?

    The main problem is that I would change passwords in future and I want that every post and page update it’s password when I change it.

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey @vkristic,

    instead of using another shortcode I have build a function in 3.1.8 which you can use in your templates.

    Here is an example:

    if ( true === passster\PS_Conditional::is_password_valid( '123' ) ) {
         the_content();
     }

    Pass in your password and the function will handle the rest for you ??

    Best regards,
    Patrick

    Thread Starter vkristic

    (@vkristic)

    It works great! Thank you!

    Thread Starter vkristic

    (@vkristic)

    Hi Patrick, I just upgraded to Passster Pro and this solution for templates isn’t working any more with multiple passwords.

    I tried with this:

    <?php
    		if ( true === passster\PS_Conditional::is_password_valid( '123', '456', '789' ) ) {
        	 the_content();
     		} ?>

    Only first password (123) works.

    • This reply was modified 6 years ago by vkristic.
    patrickposner

    (@patrickposner)

    Hey @vkristic,

    thanks for your message and your upgrade!

    Yes, the function from this post is for single passwords only.
    If you want to use it with multiple passwords you need ?are_passwords_valid“.

    I have build you a small example here:

    $passwords = array('123', '345', '678' );
    
    if ( true === passster\PS_Conditional::are_passwords_valid( $passwords ) ) {
         the_content();
    }

    Best regards,
    Patrick

    Thread Starter vkristic

    (@vkristic)

    Something is still wrong.

    I put this:

    $passwords = array( '123', '456', '789' );
    
    if ( true === passster\PS_Conditional::are_passwords_valid( $passwords ) ) {
         	the_content();
    }

    And set multiple passwords in plugin settings to 123, 456, 789

    But it does not work.

    Web: https://download.bug.hr

    • This reply was modified 6 years ago by vkristic.
    patrickposner

    (@patrickposner)

    Hey @vkristic,

    sorry my fault. There is no need for an array, so use this instead:

    $passwords = '123,345,678';
    
    if ( true === passster\PS_Conditional::are_passwords_valid( $passwords ) ) {
         the_content();
    }

    That should do the trick.

    Thread Starter vkristic

    (@vkristic)

    Thank you! This is it… Regards!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘do_shortcode command and wrapping content’ is closed to new replies.