• Resolved jaykdoe

    (@jaykdoe)


    I am working on a custom layout using the do_shortcode() function within a page template.

    The only instance that works is this:
    echo do_shortcode( '[pmpro_account]' );

    Any other shortcode from the list simply outputs the text of the shortcode.

    For instance, using
    echo do_shortcode( '[pmpro_account]' );

    Simply displays “[pmpro_billing]” rather than displaying the billing page content.

    Any ideas on why this is happening or how to fix it?

    https://wordpress.org/plugins/paid-memberships-pro/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey jaykdoe,

    As I am waiting for someone to respond to my support thread, I figured I will try to help you out. I am not sure why the do_shortcode function isn’t working as intended but I can offer an alternative. You can use the “the_content” filter. The filter executed shortcodes before they are displayed in page content. The alternative would look like this:

    echo apply_filters('the_content', "[pmpro_account]");

    In my opinion, whether or not this is proper is up for debate and depends on how exactly you are using it. Either way, this should work fine.

    I’ll check this thread to see if it worked.

    Thread Starter jaykdoe

    (@jaykdoe)

    Austin,

    Thank you very much for your suggestion. Unfortunately I’m still running in to the same issue where the [pmpro_account] shortcode seems to work but none of the others do. I appreciate your input, but hopefully pmpro support will look into this and help identify the issue when they have time.

    Thanks again!

    I believe what you’re describing is known behavior; the PMPro shortcodes won’t work with the do_shortcode call. Try this as a possible solution:

    //make sure this is called before the header loads (may want to put it in a wp or init hook and make sure it only runs on the right page
    include(PMPRO_DIR . "/preheaders/levels.php");
    
    //put this where you want the page content to show up
    include(PMPRO_DIR . "/pages/levels.php");
    
    //or this inside your template:
    <?php include( get_stylesheet_directory() . "/paid-memberships-pro/pages/account.php"); ?>

    Separately, there are some updates re: shortcodes in today’s 1.8.4.2 release.

    http://www.paidmembershipspro.com/2015/05/pmpro-update-1-8-4-2/

    Thread Starter jaykdoe

    (@jaykdoe)

    WOW, essaysnark thank you!! This works exactly as I had hoped the do_shortcode call would.

    Thank you very much for chiming in on this and providing your knowledge of the known issue, as I’m not sure I would’ve solved this on my own.

    It doesn’t look like the recent updates resolved the shortcode issue I was facing, but your code did.

    Thanks again to both you and Adam for helping me resolve this.

    Can’t claim much credit – your problem sounded familiar to something we’d encountered, but the actual solution came from a quick search on the PMPro Members Support Forum. If you’re doing anything beyond a vanilla install, paying for the support is well worth it, IMO, if only because it gives you access to that. (No, not affiliated with them, just happy users.)

    Anyway glad you got past this one! Good luck with your site.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘shortcodes do not work correctly using do_shortcode() function’ is closed to new replies.