0

I'm new to WP and trying to configure the 'My Account' page on a WP site. The site uses the Paid Memberships Pro (PMP) plugin. In the WP admin console > Pages, there is a page called 'My Account'. The content of the page is '[pmpro_account]', which is the shortcode for the PMP account page. From what I can tell, the shortcode is ultimately rendered by the pmpro_account.php page. However, the code on that page does not match what you see when you browse to the page. After more digging, I noticed the page uses a template, called 'My Account':

Page Template Selector

I found the template (myaccount-page.php), which just does this:

get_template_part( 'loop', 'myaccount' );

then found the loop page (loop-myaccount.php), which just does this:

... <?php the_content(); ?> ...

After searching all of the files, I found an account.php, which contains the actual content that I see when browsing to the page. How did WordPress know to render this page? How does WP determine what gets generated when there is page, a shortcode and a template?

  • 1
    the_content() call the content of the page => "[pmpro_account]" => the shortcode is replaced by is content => the file account.php – mmm Aug 30 '15 at 21:16
  • @mmm What do you mean by "the shortcode is replaced by is content => the file account.php" ? – rycornell Aug 30 '15 at 21:29
2

Nice sleuthing. Every single person on this SO site has been foiled by something exactly like this at one point or another with the WordPress template hierarchy.

You might think of this backwards though. All the steps you found lead you back to the shortcode [pmpro_account] which gets output in the loop-myaccount.php by way of the_content().

That shortcode is defined in their code base like this:

add_shortcode('pmpro_account', 'pmpro_shortcode_account');

That's telling WordPress: when you sees the [pmpro_account] shortcode, run the function called pmpro_shortcode_account. In that same file, up at the top, is a function called pmpro_shortcode_account(). That function has all of the HTML and logic in it.

It doesn't look like they have a way to overwrite that code via filter but I've never used the plugin so I can't say for sure. They have a list of all of the available hooks and filters in their docs.

If worse comes to worse and you need to change the HTML output. you could remove the shortcode call from the editor and try replicate the functionality of pmpro_shortcode_account() within your loop-myaccount.php template.

|improve this answer|||||
  • How does it know to render account.php? Would there be something in that file that overwrites the shortcode? – rycornell Aug 30 '15 at 21:43
  • I'm not sure what account.php is. I only see one in their repo and all it does is call the shortcode (which calls the file I pointed to. github.com/strangerstudios/paid-memberships-pro/… – Will Aug 30 '15 at 21:49
  • there is another account.php which is in the themes folder: \themes\mytheme\paid-memberships-pro\pages\account.php. – rycornell Aug 30 '15 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.