These shortcodes can be used anywhere in your site, either in post content or widgets, or via template files using the WordPress do_shortcode function.

[membership] Shortcode

Use this shortcode to hide or show content based on the current user’s membership level. The shortcode can be used in any post or widget to show certain content to certain membership levels.

[pmpro_member] Shortcode

Use this shortcode to show specific information on the current “logged in” member.

The shortcode accepts two attributes:

  • field: Required; Specify which piece of member information to output. The available field values are those included the users table, usermeta table (including custom user fields or fields added by other plugins), and all fields related to membership that are stored in custom Paid Memberships Pro tables. You can only specify one value for the field attribute.
  • user_id: Optional; Set a specific User ID to show member info about. If you do not include this field, the shortcode will pull info from the current logged in user.
[pmpro_member field="last_name"]

If you want to show multiple fields in the same section, repeat the shortcode like the following example:

Welcome, [pmpro_member field="first_name"] [pmpro_member field="last_name"]. It's good to have you here!

Supported “field” Values Include:

Membership Level Fields:

  • membership_id
  • membership_name
  • membership_description
  • membership_confirmation
  • membership_initial_payment
  • membership_billing_amount
  • membership_cycle_number
  • membership_cycle_period
  • membership_billing_limit
  • membership_trial_amount
  • membership_trial_limit
  • membership_startdate
  • membership_enddate

Fields Stored in the users table

  • user_login
  • first_name
  • last_name
  • user_email
  • user_url
  • user_registered
  • display_name

Specialty Fields:

  • avatar

Note: This shortcode is very powerful. It’s capable of outputting any user or user meta field for the logged in user or a specific named user (by ID). For this reason and the potential privacy and security risks associated with displaying user info, only users with the edit_users capability (given to people with the Administrator role) can add this shortcode to content.

Much like how WordPress core filters the script tag from content before updating the database, we also filter out this shortcode. If a user without the edit_users capability adds this shortcode to post content (like a page, post, or CPT), widgets, or menus, we remove it before saving to the database. We will also remove the shortcode if it exists in post content and someone without this capability edits the post.

[pmpro_checkout_button] Shortcode

This shortcode inserts a formatted link to the checkout page for the attributed membership level. It’s useful when you build a custom membership level landing page or custom levels page using your theme or a page builder.

Shortcode attributes:
  • class: the button’s CSS class. Default: pmpro_btn.
  • level: the level ID to display the checkout link for.
  • text: the text of the checkout button. Default: “Sign Up for {level name} Now”.
[pmpro_checkout_button class="pmpro_btn" level="1" text="Buy Now"]
Was this article helpful?
YesNo