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

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; ?>
| improve this answer | |
  • 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) – 1400309 May 9 '19 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 – Vishwa May 10 '19 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/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.