• Resolved sanji41

    (@sanji41)


    Hi,

    I have a theme that kinda needed a PHP shortcode to hide several divs from the user. Thing is, when I use <?php echo do_shortcode('[groups_member group="cookbook"]'); ?> It doesn’t work, the end shortcode shows and the text that should be hidden isn’t. I know this isn’t normal, but I wanted to know if the plugin is capable of using the PHP shortcode or not? Or there’s something wrong with the theme?

    Theme Name: Food And Cook
    WP: 4.0

    Cheers

    https://www.ads-software.com/plugins/groups/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Anonymous User 9906592

    (@anonymized-9906592)

    I’m curious about this as well. I can get the shortcodes to display group-specific content just fine via the editor, but when it comes to doing “do_shortcode()” calls actually in the php, I’ve had zero luck. For example, this does not work:

    <?php echo do_shortcode('[groups_non_member group="Registered"]') ?>
    //put content
    <?php echo do_shortcode('[/groups_non_member]') ?>

    Being able to do this would be incredibly useful.

    Plugin Author itthinx

    (@itthinx)

    I can imagine that the problem is the whole thing has to be within one call. Try:

    $content = '[groups_member group="Registered"]';
    $content .= 'Only registered users should be able to see this.';
    $content .= '[/groups_member]';
    echo do_shortcode( $content );

    Works perfect, maybe will be very useful if you can provide other users who don’t know PHP (like me) tutorial to do something like:

    <?php
    $content = ‘[groups_member group=”Registered”]’;
    $content .= ‘<?php echo ?>’;
    $content .= ‘[/groups_member]’;
    echo do_shortcode( $content );
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Shortcode for Groups Doesn't work?’ is closed to new replies.