Solutions keyboard_arrow_down keyboard_arrow_up
Our Solutions
Ontraport's solutions work together to give you everything you need to run your business in one centralized, easy-to-use platform.
Resources keyboard_arrow_down keyboard_arrow_up
Resources
Find free content on the latest marketing strategies, using Ontraport in your business, and finding the right software.
Visit the blog
University Pricing Chat
clear

WordPress shortcodes

Last updated on: December 12, 2024

When adding content on your WordPress site, you can control which membership levels can see specific content on the same page by using shortcodes. Below, we have included examples of each shortcode available for showing and hiding content on your WordPress site. After you determine your shortcodes, follow these steps to insert the shortcodes on your membership site pages.

WordPress membership sites are available to Plus levels and above.


About Shortcodes

First, here are the shortcodes available:

You can use these in a variety of ways to show and hide certain content based on:

  1. Membership Level
  2. Tags
  3. Ontraport Contact Status
  4. Cookie

Show/Hide Content Based on Membership Level

In the following examples we are using the membership levels Bronze, Silver and Gold. The membership level we have added to the shortcode is shown in blue.

+ Has one

This shortcode will display the content if the member has any of the membership levels. If the member has a single membership level listed in the shortcode, then they are able to view your content.

What the editor inserts: [show_if has_one=””]content[/show_if]

Edited to show to Bronze members only: [show_if has_one=”Bronze“]content [/show_if]

Edited to show to Bronze or Silver members but not Gold: [show_if has_one=”Bronze, Silver“]content [/show_if]

+ Has all

This shortcode limits the display to only those members who have all of the included membership levels. For content to show, the member must have every level listed in the shortcode — if they only have one, then the content will not be visible to them.

What the editor inserts: [show_if has_all=””]content[/show_if]

Edited to show to Bronze members only: [show_if has_all=”Bronze“]content[/show_if]

Edited to show to members with BOTH Bronze and Silver memberships: [show_if has_all=”Bronze, Silver“]content[/show_if]

A member with only Bronze membership will NOT see the content, as they must have BOTH Bronze and Silver

Does not have one

For the content to show, the member must not have any of the membership levels listed. Contacts with one of the listed membership levels will not be able to view the content.

What the editor inserts: [show_if not_one=””]content[/show_if]

Edited to show to members WITHOUT Bronze membership: [show_if not_one=”Bronze“]content[/show_if]

The content is shown to members without the Bronze level.

Edited to show only to members WITHOUT Bronze or Silver: [show_if not_one=”Bronze,Silver“]content[/show_if]

The content is not shown to members with either Bronze or Silver memberships.

+ Does not have any

The content inside the shortcode will be shown if the member doesn’t have all of the membership levels listed. When multiple membership levels are placed within this shortcode, the content isn’t visible to contacts who have every level listed. If the shortcode contains multiple levels, and the contact only has one of them, then the content will be visible to them.

What the editor inserts: [show_if not_any=””]content[/show_if]

Edited to show to everyone without Bronze membership: [show_if not_any=”Bronze“]content[/show_if]

Edited to exclude anyone with BOTH Bronze and Silver membership: [show_if not_any=”Bronze,Silver“]content[/show_if]

If the member does not have either level or only has Bronze or Silver, then the content will still be visible.

Show/Hide Content Based on Tags

The member must be logged in for these shortcodes to display or hide content.

Has tag(s)

If the contact has the tags listed, they will be able to see your selected content.

What the editor inserts: [show_if has_tag=””]content[/show_if]

Edited to show to logged in members with the Tag “Action”: [show_if has_tag=”Action“]content[/show_if]

+ Does not have tag

If the contact has the tags listed, they will not be able to see the content.

What the editor inserts: [show_if does_not_have_tag=””]content[/show_if]

Edited to show content to logged in members who do NOT have the Tag “Action”: [show_if does_not_have_tag=”Action“]content[/show_if]

Show/Hide Content Based on Ontraport Contact Status

The member must be logged in for these shortcodes to display or hide content. These shortcodes are used to display or hide content based on if the member is a contact in your Ontraport account. These do not require any editing of the shortcode that is entered into the editor.

Is a contact

If the WordPress user is a contact in your Ontraport account, then they will be able to see your selected content.

What the editor inserts: [show_if is_contact]content[/show_if]

Is not a contact

If the WordPress user is not a contact in your Ontraport account, then they will be able to see your selected content.

What the editor inserts: [show_if not_contact]content[/show_if]

Show/Hide Content Based on Cookie

These shortcodes work even if the member is not logged in. PilotPress checks for Ontraport’s cookie and shows or hides content based on the presence of that cookie. These do not require any editing of the shortcode that is entered into the editor.

Is a cookied contact

If the browser used to view your page has Ontraport’s cookie, then the content is visible to them.

What the editor inserts: [show_if is_cookied_contact]content[/show_if]

Is not a cookied contact

If the browser used to view your page does not have an Ontraport cookie stored, then the content is visible to them.

What the editor inserts: [show_if not_cookied_contact]content[/show_if]

Resync Contacts

This shortcode retrieves information from Ontraport when the page loads to resync the contact. It does not display or hide content. However if your contact has changed membership levels, it will allow your site to use the updated information about the contact’s membership level.

What the editor inserts: [pilotpress_sync_contact]

The resync shortcode has built-in looping protection to protect your site from multiple page refreshes. After the page initially loads, the shortcode sets a timer and will accept two page refreshes in a five-minute period. After the second page refresh, the shortcode will be inactive for five minutes. This prevents a loop condition from slowing down or crashing your membership site.

Testing Membership Shortcodes

When using the “PilotPress Admin View As” feature, you can only test one membership level at a time. To test the shortcodes that require ALL of the membership levels to be present, for example [show_if has_all=”Bronze,Silver”]content[/show_if], follow the process below.

  1. Create a new contact for testing purposes. Add a membership level to the contact. Keep Ontraport open to this contact record.
  2. Open a new private tab or window in your browser.
  3. In the private tab or window, clear the cookies for your WordPress site.
  4. Go to the default WordPress login page by adding “/wp-login.php” to your domain: http://your-domain.com/wp-login.php
  5. Log in as your new contact. Test the functionality of your membership levels and shortcodes.
  6. To test a new membership level, log the contact out of WordPress. Add the new membership level in Ontraport and log the contact back into WordPress.

Redirect Logins by Membership Level

In PilotPress settings, you can select which page your customers will go to after they log in. If you want to send your members to different pages based on their membership level, you can do it using a shortcode that contains a meta refresh tag. To accomplish this, follow the steps below.

Note, WordPress classic blocks will not work for this function.

  1. Go to the page you selected in your post-login redirect settings.
  2. Add an HTML block to your page.
  3. Add a “show_if has_one” membership shortcode described above.
  4. Replace the content for the shortcode with <META http-equiv=”refresh” content=”0;’URL=URL of the page you want to redirect to‘” />

For example, if you want to send your “Gold” members to http:// your-domain.com/gold after they log in, your shortcode would look like this:

[show_if has_one=”Gold”]

< META http-equiv=”refresh” content=”0;URL=’http:// your-domain.com/gold'” />

[/show_if]

Related university lessons

Publishing on WordPress
Follow the steps for publishing Ontraport pages to your existing WordPress site using Ontrapages, a WordPress plugin.
How to protect your membership content
In this video, you’ll learn how to set up different membership levels and permissions so you can protect your membership site content.
PilotPress overview
Learn how our PilotPress plugin works so you can use it to turn your WordPress site into a membership site.
arrow_drop_down_circle
Divider Text

Related support articles

arrow_forward
How to determine which Ontraport membership solution is right for your business
arrow_forward
Social login for membership sites
arrow_forward
Getting started with Ontraport Membership Sites

 Pro tips

Tip #1: You cannot nest the show_if tags due to WordPress limitations. "Nesting" refers to a structure like this: [show_if has_one="Bronze"] [show_if has_one="Silver"]Bronze and Silver member content here [/show_if][/show_if] If you want to show content to both Bronze and Silver, use one shortcode, and separate your membership levels with a comma like the example above.
Tip #2: The resync shortcode has built in looping protection to protect your site from multiple page refreshes. After the page initially loads, the shortcode sets a timer and will accept two page refreshes in a five minute period. After the second page refresh, the shortcode will be inactive for five minutes. This prevents a loop condition from slowing down or crashing your membership site.
Tip #3: In each of the example shortcodes, the word "content" is the content of the page you want to display or hide. It can be text, images, videos, or any other content you normally have in a WordPress page or post, and it can be any length.
Features
Company
Resources
Live events
Access
© Ontraport 2024
playlist_add_check
PCI DSS, Level 1
security
Privacy Shield Certified
[bot_catcher]