What is a shortcode?
Shortcodes are small placeholders you can insert almost anywhere within your WordPress page and post content. When the page is viewed by a visitor, those placeholders get processed and replaced with some dynamically generated content instead.
Currently Available Shortcodes
- Account Related Shortcodes
- Subscription Related Shortcodes
- Login Related Shortcodes
- Unauthorized Access Related Shortcodes
- Registration Related Shortcodes
Account Related Shortcodes
Show a Link to the Account Page
[mepr_account_link]
Shows a link to the Account page in MemberPress. It can be used on any page or post.
Display the Account Information Form
[mepr_account_form]
Shows the user account information form. This typically isn't used unless you want to show account information somewhere besides the MemberPress Account page that exists by default. This can also be useful for folks using WPML who create separate account pages for each language.
Display User Account Information
[mepr_account_info field="slug"]
This shortcode will show the currently logged-in user's first name, based on the “slug”:
Slug | Result |
full_name | John Doe |
full_name_last_first | Doe, John |
first_name_last_initial | John D. |
last_name_first_initial | Doe, J. |
first_name | John |
last_name | Doe |
user_login | johndoe |
user_email | johndoe@email.com |
nickname | johndoe |
description | (aka Biographical info) |
mepr-address-one | 123 Fake Street |
mepr-address-two | Apt. 123 |
mepr-address-city | Vidor |
mepr-address-state | Texas |
mepr-address-zip | 77662 |
mepr-address-country | USA |
mepr_user_message | The “Custom MemberPress Account Message” you have defined for the member in their profile |
user_registered | The date/time the user first joined your site |
display_name | johndoe |
ID | The unique ID assigned to the user upon registration. Must be entered as ID, not id. |
“Your custom Slug” | Any of the Custom Account Field slugs in the MemberPress Settings. |
For example, you might want to show the logged-in user's first name somewhere on a page. You would use the following shortcode:
[mepr_account_info field="first_name"]
Thus, if a user named John Doe visits the page, it will show John in the place where the shortcode was placed.
Also, keep in mind that MemberPress custom field data can be collected only on the Account or membership registration pages. The shortcode added to your custom pages will not display any custom fields you added to your forms.
Display a Link to User-Uploaded Files
[mepr_user_file slug="mepr_slug" user_id=""]Link Text[/mepr_user_file]
This shortcode displays a link to view or download a file uploaded by a user.
Setup Instructions:
- Replace mepr_slug with the name of your custom field from MemberPress > Settings > Fields tab.
- If you don't add a user_id parameter, it shows the file for the logged-in user.
- If the user_id parameter is given, the shortcode shows the file for that user.
- The text between the tags is the link text for the file.
You don't have to include the closing tag. If you leave it out, the link will just show normally.
Subscription Related Shortcodes
Display a List of Subscriptions
Displays a list of the current user's active and inactive subscriptions.
[mepr_list_subscriptions status="all"]
Since the MemberPress 1.9.28 version have introduced an optional status attribute.
Status Options:
- status=”all” or no status attribute – displays all active and inactive subscriptions;
- status=”active” – displays only active subscriptions;
- status=”expired” – displays only inactive subscriptions.
You can set the status to “all” or remove it like this:
[mepr_list_subscriptions]
As you can see above, it will display the default current active and inactive subscriptions.
[mepr_list_subscriptions status="active"]
When you set the status to “active”, you will see the current user's active subscriptions.
[mepr_list_subscriptions status="expired"]
You can also display the current user's inactive subscriptions by using the “expired” status.
Sorting Options:
The subscriptions list can be sorted by date:
[mepr_list_subscriptions orderby="date"]
Or title:
[mepr_list_subscriptions orderby="title"]
Sort Order Options:
They can be sorted in ascending:
[mepr_list-subscriptions orderby="title" order="asc"]
Or descending order:
[mepr_list_subscriptions orderby="title" order="desc"]
Login Related Shortcodes
Display Login or Logout Links
Login Link Shortcode:
[mepr_login_link]
Logout Link Shortcode:
[mepr_logout_link]
The above two shortcodes are both identical. They show login or logout links based on the current user's logged-in status.
The login link takes users to the login page, where they can log in. The logout link logs them out and sends them to the Redirect URL, which you can set in Dashboard > MemberPress > Settings > Account tab.
Display a Login Form
[mepr_login_form use_redirect="true"]
This shortcode shows a login form on a page or post. It can be used anywhere. When use_redirect = “true“, MemberPress will redirect the user to the login redirect URL setting located in the Dashboard > MemberPress > Settings > Account tab.
Unauthorized Access Related Shortcodes
Display the Unauthorized Message
[mepr_unauthorized_message]
Shows the unauthorized message wherever this is placed. If you've set MemberPress up to redirect unauthorized visitors to a specific URL, then it is recommended to use this shortcode on that unauthorized page.
Show or Hide Content Based on Login Status
[mepr_show]Content to show in here[/mepr_show]
[mepr_hide]Content to hide in here[/mepr_hide]
Both shortcodes above support if=”X” attribute, where “X” can be “loggedin” or “loggedout”.
Examples:
[mepr_show if="loggedin"]You’re logged in, congratulations![/mepr_show]
[mepr_show if="loggedout"]You’re now logged out![/mepr_show]
As shown above, both shortcodes are checking whether the user is logged in or logged out. This shortcode is not related to the memberships the user has purchased.
Show or Hide Content Based on Membership Access
[mepr_active {parameters go here - see below}]Content to protect in here[/mepr_active]
Used to show or hide content on pages throughout your site. This shortcode supports the following parameters (parameters marked with * are required. Only one parameter in red below can be applied per shortcode):
Supported Shortcode Parameters
Shortcode Parameters | Description |
rule(s) * | If you plan to use a single Rule ID, then set this to rule=”X”. If you plan to use multiple Rule ID's, then set this to rules=”X, XX, XXX”. Where X's = the ID's of the Rule(s). Where to find a Rule's ID? |
membership(s) * | If you plan to use a single Membership ID, then set this to membership=”X”. If you plan to use multiple Membership IDs, then set this to memberships=”X, XX, XXX”. Where X's = the ID's of the Membership(s). Where to find a Membership's ID? |
ifallowed* | When set to ifallowed=”show”, the content in-between is shown to authorized members only. When set to ifallowed=”hide”, the content is hidden from authorized members. |
unauth | If you plan to use a single Membership ID (Where to find a Membership's ID?), then set this to one of the possible values:
Note: when set to “message” or “both” AND the rule has a custom unauthorized message, it will display the custom unauthorized message instead of the global one. |
unauth_message | Use this to override the default unauthorized message. This only applies when the “unauth” attribute above is set equal to “message” or “both”. |
An example shortcode using all the above attributes might look like the following:
[mepr_active rules="1, 2, 3" ifallowed="show" unauth="message" unauth_message="Download link hidden, please login or purchase a membership to view."]<a href="#">Download Link Here</a>[/mepr_active]
Registration Related Shortcodes
Display Group Pricing Boxes
[mepr_group_price_boxes group_id="123"]
This shortcode is helpful if you want to place content above and below the group pricing boxes. If you're using this on the Group page itself, there's no need to specify a group_id. If you want to use it elsewhere on your site, you will need the group_id attribute.
Display a Link to a Membership Page
[mepr_membership_link id="0"]Link text in here[/mepr_membership_link]
Shows a link to the Membership identified by “id”. Replace id=”0″ with the real Membership ID. Find out how to get a Membership ID.
Display a Link to the Membership Access URL
[mepr_membership_access_url id="123"]Link text here[/mepr_membership_access_url]
Uses the Membership access URL set in the “Membership access URL” setting under the Membership Options section. Use this anywhere on your site to give the member a link to the Membership access URL. Membership id=”123″ should be replaced with the ID of your Membership. Where to find a Membership ID?
Display the Membership Registration Form
[mepr_membership_registration_form]
It is helpful if you want to place content above and below the Membership registration form. It can ONLY be used on the Membership page.
[mepr_membership_registration_form id="123"]
You can use this shortcode on any WordPress page, post, or custom post type to display the membership registration form of a specific membership. Simply replace 123 with your own membership's unique ID. Where to find a Membership ID?
Display Custom Instructions for Offline Gateway Users
[mepr_offline_instructions gateway_id="abc-123"]Custom message here.[/mepr_offline_instructions]
This shortcode can be used on your Thank-You pages to display any type of message specific to users who registered via your offline gateway option. For gateway_id=”abc-123″, enter your gateway's ID. It could be used to provide additional instructions for users when they purchase your membership through your offline gateway.
Display Active Membership Titles
[mepr_user_active_membership_titles userid="" message=""]
Shows the members' currently active membership names. If no userid is present, then it'll default to the current member. If the member has more than one active membership, the names will be separated by a comma.
Since the MemberPress 1.9.38 version have introduced an optional message attribute. It can be used when you want to display a custom message when a user doesn't have any active subscriptions. If you leave it empty, the shortcode will not display any message.
Track E-commerce Conversions
[mepr_ecommerce_tracking]Message with %%variables%% in here[/mepr_ecommerce_tracking]
This shortcode can ONLY be used on the thank you page or in custom thank you page messages. It does not work anywhere else.
Supported Shortcode Variables
It supports the following %%variables%%, which are automatically replaced with values from the purchase.
Variable | Description |
%%subtotal%% | Outputs the sub-total of the first payment. If the first payment was a free trial period, this will be 0.00. If the first payment was a paid trial period, this will be the subtotal of the trial period payment. |
%%total%% | Outputs the sub-total + tax of the first payment. If the first payment was a free trial period, this will be 0.00. If the first payment was a paid trial period, this will be the total of the trial payment. |
%%tax_amount%% | Outputs the tax amount of the first payment. If the first payment was a free trial period, this will be 0.00. If the first payment was a paid trial, it will be the tax amount of the paid trial payment. |
%%tax_rate%% | Outputs the user's tax rate on this purchase. |
%%txn_num%% | Outputs the Transaction Number of the first payment. For recurring payments, this transaction number will most likely be a temporary number generated by MemberPress as it takes some time for the payment gateway to process the first payment. |
%%sub_id%% | Outputs the ID of the recurring subscription. If the purchase made is not recurring, this variable will not be replaced. |
%%txn_id%% | Outputs the ID of the first transaction. For recurring subscriptions, this ID will in most cases be the ID of the hidden grace-period |
%%sub_num%% | Outputs the Subscription Number of the recurring subscription. If the purchase made is not recurring, this variable will not be replaced. With PayPal Standard, this may be a temporary number generated by MemberPress as it can take some time for the gateway to update the record with a valid subscription number. |
%%membership_amount%% | Outputs the regular recurring cost of a recurring subscription. If the purchase made is not recurring, this variable will not be replaced. |
%%trial_days%% | Outputs the number of days in the paid or free trial period for a recurring subscription. If the purchase made is not recurring, this variable will not be replaced. |
%%trial_amount%% | Outputs the cost of the trial period for a recurring subscription. If the purchase made is not recurring, this variable will not be replaced. |
%%username%% | Outputs the member's username. If you have configured the MemberPress Settings page to make the user's email address their username, then this will output their email address. |
%%user_email%% | Outputs the member's email address. |
%%user_id%% | Outputs the member's WordPress User ID. |
%%membership_name%% | Outputs the name (title) of the Membership purchased. |
%%membership_id%% | Outputs the ID of the Membership. |