• Resolved byrnesdigital

    (@byrnesdigital)


    Hey,

    Thanks for the plugin, loving it so far. I’m having some issues with the PHP in Tables extension. I’ve tried two different ways of implementing PHP in the cell and I get 2 different results, neither are the desired. I’m using it with the Simple WordPress Membership plugin.

    This code doesn’t show the conditional content when the user is logged in to the plugin.

    <?php if(SwpmMemberUtils::is_member_logged_in()) : ?>
    <b>DANTE’S CORNER</b>
    <a href="http://somebodyelsesmoney.com/demo/dantes-corner-subscriber/"><img src="http://somebodyelsesmoney.com/demo/wp-content/uploads/2016/10/Dantes.png" alt="dantes" width="117px" height="132px" class="alignleftsize-full wp-image-152" <a href="http://somebodyelsesmoney.com/demo/dantes-corner/"><a/>
    
    <?php else : ?>
    <b>DANTE’S CORNER</b>
    <a href="http://somebodyelsesmoney.com/demo/dantes-corner"><img src="http://somebodyelsesmoney.com/demo/wp-content/uploads/2016/10/Dantes.png" alt="dantes" width="117px" height="132px" class="alignleftsize-full wp-image-152" <a href="http://somebodyelsesmoney.com/demo/dantes-corner/"><a/>
    
    <?php endif; ?>

    This one does show the conditional content but it shows it whether or not the user is logged into the plugin.

    
    <?php if(SwpmMemberUtils::is_member_logged_in()){ echo '
    
    <b>DANTE’S CORNER</b>
    <a href="http://somebodyelsesmoney.com/demo/dantes-corner-subscriber/"><img src="http://somebodyelsesmoney.com/demo/wp-content/uploads/2016/10/Dantes.png" alt="dantes" width="117px" height="132px" class="alignleftsize-full wp-image-152" <a href="http://somebodyelsesmoney.com/demo/dantes-corner/"><a/>
    
    '; }else{ echo '
    <b>DANTE’S CORNER</b>
    <a href="http://somebodyelsesmoney.com/demo/dantes-corner"><img src="http://somebodyelsesmoney.com/demo/wp-content/uploads/2016/10/Dantes.png" alt="dantes" width="117px" height="132px" class="alignleftsize-full wp-image-152" <a href="http://somebodyelsesmoney.com/demo/dantes-corner/"><a/>'; } ?>
    

    I need it so that if a user is logged in through the plugin, the subscriber link shows up in the table. If not, the regular link. I know the if(SwpmMemberUtils::is_member_logged_in()) is working because it works for other parts of the site.

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    This is likely caused by the caching that TablePress uses. Please try turning that off by adding adding an extra parameter to the Shortcode, like
    [table id=123 cache_table_output=false /]

    Regards,
    Tobias

    Thread Starter byrnesdigital

    (@byrnesdigital)

    Hi Tobias,

    Thanks for the response. I’ve tried that with no success. I’ve tried it with both of the above methods. I’m new to php so I’m not sure which is better or why one is showing one thing and another one another thing.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    just to be sure, you have installed the TablePress Extension from https://tablepress.org/extensions/php-in-tables/ to enable using PHP in table cells, right?

    Regards,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Conditional content in cells using PHP in table extension’ is closed to new replies.