Support » Plugin: Global Content Blocks » [Plugin: Global Content Blocks] Shortcode in block only works sometimes

  • Resolved Ricki


    I am trying to insert shortcode into a content block. The shortcode is setup by a plugin called Wishlist Member.

    The shortcodes that do not use enclosing content work just fine in GCB, but any shortcodes that have enclosing content do not.

    Shortcodes with enclosing content appear on the front-end.

    This shortcode works just fine.

    This shortcodes does not work.
    [nonmember]Display this message to non-members[/nonmember]

    The PHP code I have inserted in GCB is:

    if (is_user_logged_in()) {
         $message = do_shortcode('[contentblock id=3]');
         echo do_shortcode('[nonmember]' . $message . '[/nonmember]');;
    } else {
         echo do_shortcode('[contentblock id=2]');

Viewing 1 replies (of 1 total)
  • Plugin Author benz1


    Hi Ricki,

    From my developer:

    The example provided is not very clear, but I have a suggestion of code that might help you:
    you can create a PHP block, and use this code in it:

    if(is_user_logged_in()) {
    echo "you are logged in! [caption] Hello there [/caption]";
    } else {
    echo "you are not logged in! [caption] Please Login [/caption]";

    This should work as intended. If would want to nest shortcodes even further, you could try embedding other content blocks (that would run their inner shortcodes). Beware of embedding a content block in itself, you would go into an infinite loop!

    Hope all of this is clear. If not, let me know exactly what you want to achieve, and we will help you further.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Global Content Blocks] Shortcode in block only works sometimes’ is closed to new replies.