Stripe Shortcodes
Shortcodes in plugins serve to dynamically display content, extend functionality, customize features, integrate with other plugins or themes, and simplify complex tasks by allowing users to easily insert specific plugin features into their website content with minimal coding knowledge. As such, here are the Stripe shortcodes to simplify the integration of Stripe into your site.
Stripe Customer Portal Shortcode
Customers need to have the ability to manage their subscription plans. This shortcode creates a button that redirects customers to the external page of the Stripe Customer Portal to manage subscriptions. A user must be logged in for the redirection to work.
[ultimatemember_stripe_customer_portal]
Stripe Order Details Shortcode
This shortcode displays the order details, billing information, and subscription status for the customer. It allows them to review the information they've provided. The order details will be displayed only when the user has completed the Stripe checkout process from the Stripe checkout page.
[ultimatemember_stripe_checkout_order_details]
Stripe Checkout Shortcode
[ultimatemember_stripe_checkout label="Annual VIP Membership – $ 299.99/year" id="38"]
Stripe Show Content Shortcode
Shortcodes to Display Active and Inactive Subscription Content or Messages
The shortcodes below allow you to display specific content or messages for users with active and inactive subscriptions:
[ultimatemember_stripe_show_content] content [/ultimatemember_stripe_show_content]
The default of this shortcode displays the content within the shortcode to users with an active subscription.
It's important to note that if UM Content Restrictions are not enabled, it's recommended to use these shortcodes. This ensures a seamless and effective display of content based on the specified plans or prices.If you want to display or show specific content for active and inactive users in a single post or page, you need to add the following attributes in the shortcode:
For active subscription
Add this attribute show_for="active"
in the shortcode as shown in the example below to show the content for active users.
[ultimatemember_stripe_show_content show_for="active"] Hello active Members [/ultimatemember_stripe_show_content]
For inactivate subscription
Add this attribute show_for="inactive"
in the shortcode as shown in the example below to show the content for the inactive users.
[ultimatemember_stripe_show_content show_for="inactive"] Hello inactive Members [/ultimatemember_stripe_show_content]
Sample Usage:
[ultimatemember_stripe_show_content show_for="active" plans="123,456,789" prices="165"] Hello Active Members by Plans/Prices [/ultimatemember_stripe_show_content]
If you have enabled Restrict Access by Stripe Plans and Active Subscription only in the Ultimate Member: Content Restriction, it's recommended to add the template=1
attribute in the show content shortcode.
This shortcode can also be integrated into PHP code, such as within a template or widget.
[ultimatemember_stripe_show_content template=1] content [/ultimatemember_stripe_show_content]
When the attribute is used, the filter to be applied is the 'Active Subscription only'. If you have not selected any plans or prices from the 'Select Stripe Plans/Prices to allow access to this post' option, the content is displayed and become accessible for users with active subscription. While users with inactive subscription might see any of the following messages. These notices or messages are intended exclusively for use with UM Content Restrictions > Restrict Access by Stripe Plans> Active Subscription only.
- "Your current subscription plan does not provide access to this {post type/taxonomy name}. Please upgrade or subscribe to a different plan to view this
{post type/taxonomy name}
" - "Your current subscription plan is not allowed to access this {post type/taxonomy name}. Please upgrade or subscribe to a different plan to view this
{post type/taxonomy name}
."
{post type/taxonomy name}
will be replaced automatically. If an archive page is restricted, it will be replaced with "Please upgrade or subscribe to a different plan to view this category " etc.
If you've chosen a Stripe plan or prices from the 'Select Stripe Plans/Prices to allow access to this post' option, only users who have subscribed to the plan or purchased the prices will be able to view the content. The logic operates on an OR basis, meaning if a plan is not selected but prices are, users who have purchased the price will still have access to the content, and vice versa.
List of shortcode attributes:
Attributes | Description & Example |
label | This attribute is required and is displayed on a page. e.g. label = "CAD 3.00 / month" |
id | The Stripe Plan ID has been generated in wp-admin > Ultimate Member > Stripe Plans > Add or Edit a Plan. When you create a Stripe plan, the shortcode will be displayed in the Stripe plan settings. |
type |
Note: When a user is already subscribed to a plan, this text will show: You're already subscribed To modify the text, you can use this filter hook: <?php add_filter("umm_stripe_already_subscribed_text", function( $text ) { return esc_attr( "You're subscribed to a plan!" ); }); ?> |
class | Add custom classes to the button or anchor element. [ultimatemember_stripe_customer_portal type="link" label="customer portal"] |
plans | This attribute is added in the shortcode [ultimatemember_stripe_show_content] to determine the display of specific content or messages tailored to users with either an active or inactive subscription, depending on the specified plan. |
prices | This attribute is added in the shortcode [ultimatemember_stripe_show_content] to determine the display of specific content or messages tailored to users with either an active or inactive subscription, depending on the specified prices. |
payment_method_types |
This attribute overrides the payment method type on the Stripe checkout page.
|
A list of valid payment method types includes:
acss_debit | affirm | afterpay_clearpay | atdpay | au_becs_debit |
bacs_debit | bancontact | btdk | boleto | card |
card_present | cashapp | eps | fpx | giropay |
grabpay | ideal | klarna | konbini | tdnk |
oxxo | p24 | paynow | pix | promptpay |
sepa_debit | sofort | us_bank_account | wechat_pay | zip |
Note: Each payment method type has to be enabled and configured in the Stripe payment method settings.
NEXT: Test Your Integration