• Resolved Dave

    (@deeve007)


    I’m trying to use “do_shortcode” for the PMP shortcodes so I can remove from the editor, to avoid my client accidently deleting them, but it’s not working, is just showing the text of the shortcode (eg, [pmpro_levels]).

    Is there a trick to making this work for this plugin?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Andrew Lima

    (@andrewza)

    Hi Dave,

    Thank you for using Paid Memberships Pro.

    Some of the shortcodes used are not ‘real’ shortcodes and will need a bit of extra code to work with the ‘do_shortcode’ method.

    Certain Paid Memberships Pro pages requires preheader (files) in order to work correctly.

    Here’s an example on how to add the pmpro_levels ‘shortcode’ to the levels page which may help get you started:

    function add_levels_shortcode_to_levels_page( $content ) {
    	global $pmpro_pages;
    	if ( ! is_page( $pmpro_pages['levels'] ) ) {
    		return $content;
    	}
    	$content .= pmpro_loadTemplate( 'levels' );
    	return $content;
    }
    add_filter( 'the_content', 'add_levels_shortcode_to_levels_page' );
    Thread Starter Dave

    (@deeve007)

    Okay so I added this to my functions file, which seems to have accounted for all relevant pages:

    function shortcodes_to_content( $content ) {
    	global $pmpro_pages;
    	
    	if ( is_page( $pmpro_pages['levels'] ) ) { 
    		$content .= pmpro_loadTemplate( 'levels' );
    		return $content;
    	} else if ( is_page( $pmpro_pages['account'] ) ) { 
    		$content .= pmpro_loadTemplate( 'account' );
    		return $content;
    	} else if ( is_page( $pmpro_pages['billing'] ) ) { 
    		$content .= pmpro_loadTemplate( 'billing' );
    		return $content;
    	} else if ( is_page( $pmpro_pages['cancel'] ) ) { 
    		$content .= pmpro_loadTemplate( 'cancel' );
    		return $content;
    	} else if ( is_page( $pmpro_pages['checkout'] ) ) { 
    		$content .= pmpro_loadTemplate( 'checkout' );
    		return $content;
    	} else if ( is_page( $pmpro_pages['confirmation'] ) ) { 
    		$content .= pmpro_loadTemplate( 'confirmation' );
    		return $content;
    	} else if ( is_page( $pmpro_pages['invoice'] ) ) { 
    		$content .= pmpro_loadTemplate( 'invoice' );
    		return $content;
    	} else if ( is_page( $pmpro_pages['member_profile_edit'] ) ) { 
    		$content .= pmpro_loadTemplate( 'member_profile_edit' );
    		return $content;
    	} else {
    		return $content;
    	}
    }
    add_filter( 'the_content', 'shortcodes_to_content' );
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘“do_shortcode” not working in theme file’ is closed to new replies.