0

I am using this plugin https://wordpress.org/plugins/content-protector/

Enter the correct password to view the content↓

[passster password="123456"]content here[/passster]

adding to php↓

<?php 

 echo do_shortcode('[passster password="123456"]content here[/passster]');

?>

He can work

But I need to hide the content that contains PHP↓

<!--<hide content>-->
    <ul class="TPlayerNv">
                            <?php echo $optplayer; ?>
                        </ul>
                        <div class="TPlayerCn BgA">
                            <div class="EcBgA" style="background-color:#EEEEEE!important;"> 
                                <div class="TPlayer">
                                    <?php echo $player; ?>
                                    <span class="AAIco-lightbulb_outline lgtbx-lnk"></span>
                                </div>
                            </div>
                        </div>
                        <span class="lgtbx"></span>
    <!--</hide content>-->

I am a newbie, he looks like this↓

<?php 

echo do_shortcode('[passster password="123456"]

<!--<hide content>-->
    <ul class="TPlayerNv">
                            <?php echo $optplayer; ?>
                        </ul>
                        <div class="TPlayerCn BgA">
                            <div class="EcBgA" style="background-color:#EEEEEE!important;"> 
                                <div class="TPlayer">
                                    <?php echo $player; ?>
                                    <span class="AAIco-lightbulb_outline lgtbx-lnk"></span>
                                </div>
                            </div>
                        </div>
                        <span class="lgtbx"></span>
    <!--</hide content>-->


[/passster]');

?>

I know that this doesn't work

help

2 Answers 2

0

I'm not sure you actually used the html inside php like you have in the bottom of the question, but do try as below.

<?php 
if( echo do_shortcode('[passster password="123456"]'); ):
?> 
<!--<hide content>-->
    <ul class="TPlayerNv">
                            <?php echo $optplayer; ?>
                        </ul>
                        <div class="TPlayerCn BgA">
                            <div class="EcBgA" style="background-color:#EEEEEE!important;"> 
                                <div class="TPlayer">
                                    <?php echo $player; ?>
                                    <span class="AAIco-lightbulb_outline lgtbx-lnk"></span>
                                </div>
                            </div>
                        </div>
                        <span class="lgtbx"></span>
    <!--</hide content>-->

<?php  echo do_shortcode('[/passster]')  endif; ?>

Update: Since I couldn't find anything related to this on your plugin's documentation, give following methods a try if above is not working

<?php if( echo do_shortcode('[passster password="123456"]') ): ?>

content here

<?php echo do_shortcode('[/passster]'); endif; ?>

or

<?php
$scode = '[passster password="123456"]';
if ( shortcode_exists( $scode ) ): ?>

content here

<?php echo do_shortcode('[/passster]'); endif; ?>
2
  • I tried the above method 1 and 2 (pages cannot be displayed) 3 (The page is normal but I can't see the password. He didn't work) Commented May 9, 2019 at 14:02
  • @1400309 Did you asked from the plugin developer if there's any way for you to have conditional action with the shortcode? They'll have a better answer than me for sure Commented May 10, 2019 at 5:22
0

You can do it like so:

<?php if ( true === passster\PS_Conditional::is_password_valid( 'passwordHere' ) ) { ?>
  <div>
    <?php echo the_content();?>
  </div>

etc...

<?php } ?>

Found and implemented from here: https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.