Support » Plugin: Outerbridge Nested Shortcodes » Really odd. Nested not working with latest updates

  • Resolved bradfranklin

    (@j66brad)


    Previous projects everything worked great. I recently went back to my code to use in new project. Unfortunately the nested aspect is not working. I’ve tried it with both my written shortcodes as well as paid plugin developer shortcodes. As “single” (not nested) all work fine. Below is my code for the is user logged in or not shortcode I’ve written. Thoughts?

    `/* CONDITION – IS_USER_LOGGED_IN
    *
    * Check if user IS signed in
    */
    function j66_check_user_signed_in ($params, $content = null) {
    //check tha the user is logged in
    if ( is_user_logged_in() ) {
    //user is logged in so show the content
    return $content;
    }

    else {
    //user is not logged in so hide the content
    return;
    }
    }

    //add a shortcode which calls the above function
    add_shortcode(‘logged-in-yes’, ‘j66_check_user_signed_in’ );

    // Check if user is NOT signed in

    function j66_check_user_signed_out ($params, $content = null) {
    //check if the user is logged out
    if ( is_user_logged_in() ) {
    //user is not logged out so hide the content
    return;
    }

    else {
    //user is logged out so show the content
    return $content;
    }
    }

    //add a shortcode which calls the above function
    add_shortcode(‘logged-in-no’, ‘j66_check_user_signed_out’ );

    // [logged-in-yes][a-shortcode-to-nest][/logged-in-yes]
    //
    // [logged-in-no][a-shortcode-to-nest][logged-in-no]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bradfranklin

    (@j66brad)

    Exciting news. I got it to work by writing my shortcode functions the correct way lol.

    If the enclosing shortcode is intended to permit other shortcodes in its output, the handler function can call do_shortcode() recursively:

    https://wordpress.org/support/topic/how-to-nest-shortcodes/

    _________

    /* CONDITION – IS_USER_LOGGED_IN
    *
    * Check if user IS signed in
    */
    function j66_check_user_signed_in ($params, $content = null) {
    //check tha the user is logged in
    if ( is_user_logged_in() ) {
    //user is logged in so show the content
    // return $content;
    return ‘<span>’ . do_shortcode($content) . ‘</span>’;
    }

    else {
    //user is not logged in so hide the content
    return;
    }
    }

    //add a shortcode which calls the above function
    add_shortcode(‘logged-in-yes’, ‘j66_check_user_signed_in’ );

    //___________________________________________________________________
    //___________________________________________________________________

    // https://wordpress.org/support/topic/how-to-nest-shortcodes/

    Plugin Author Outerbridge

    (@outerbridge)

    Great news, glad you got it sorted!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Really odd. Nested not working with latest updates’ is closed to new replies.