Since 2006, when we created the first non-PHP based WordPress custom shortcode feature, custom shortcodes have been a mainstay of our membership plugins. And with good reason.

What are Custom Shortcodes?

ActiveMember360’s custom shortcodes are an extremely versatile and practical way to include repetitive text or code (HTML, JS, CSS, PHP) into your posts, pages, widgets, etc.

Since custom shortcodes can also include third-party shortcodes as well as reference other custom shortcodes, ActiveMember360 custom shortcodes can be used in almost any situation and can be combined to create extremely powerful sets of repetitive, intelligent procedures.

Over time, you can create your own library of custom shortcodes that can be used in any of your other sites without having to constantly “re-invent the wheel” on every page, post, lesson, etc.

Where do I start?

The first step would be to create one and you would start by navigating to the “Custom Shortcode” admin page, as shown below:

On the following screen, you would click on “Add New”:

The next screen will open to something similar to the following screenshot:

  1. Enter a working name / title for your shortcode
  2. Write your code (text, HTML, javascript, CSS, etc) into the main content area, just as you would any page or post.
  3. Add any notes about this custom shortcodes, for yourself and/or others on your team.
  4. Save your work. Later on, if you want to revert to an earlier version, you will be able to use WordPress’ “revisions to retrieve it.
  5. Every shortcode created will have a unique name, based on the name entered in Step 1. This item can be overwritten manually and ActiveMember360 will still ensure that the new name remains unique.

Short Code Parameters

Just like regular shortcodes, custom shortcodes can also use “parameters” (sometimes called “attributes”). These parameters enable you to use a shortcode to do different things based on the values passed to it.

If your custom shortcode was named [mbr_custom001], when used with parameters, it would look as follows:

[mbr_custom001 color1='blue' color2='yellow' color3='green']

In this case, the parameters would be “color1“, “color2” and “color3” and their respective values would be “blue, “yellow” and “green“. If values contain a space, enclosing the value in single or double quotes is mandatory, as is the case with any other WordPress shortcode. For that reason, we recommend you always enclose parameter values in quotes so that your work is consistent throughout the site and making any potential errors easier to find and/or rule out.

When the custom shortcode is being resolved by ActiveMember360, the values “blue, “yellow” and “green” will be used wherever “color1“, “color2” and “color3” are referenced inside your custom shortcode. You can think of it as something akin to mail merge in your ActiveCampaign templates.

How to Use Parameters inside Custom Shortcodes

To reference parameters inside your custom shortcodes, you would use the basic %%name%% format.

Because of their similarity in purpose, we use the double-percent %% delimiter to remind you of ActiveCampaign’s percent sign % delimiter for mail merge codes.

If you placed the following custom shortcode on one of your pages:

[mbr_custom001 color1='blue' color2='yellow' color3='green']

and your custom shortcode contained the following:
Mixing %%color1%% and %%color2%% yields %%color3%%

The result would be:

  • Mixing blue and yellow yields green.

If you’re wondering why this would be helpful, you should remember that on another page, you could “call” the same custom shortcode but with different values:

[mbr_custom001 color1='red' color2='yellow' color3='orange']

Without requiring any changes on your part, your custom shortcode would now resolve to:

  • Mixing red and yellow yields orange.

Using Regular Shortcodes in your Custom Shortcodes

ActiveMember360’s custom shortcode processor can pretty much handle anything you throw at it. In a custom shortcode, you can include:

  • References to other ActiveMember360 shortcodes
  • References to WordPress and third-party shortcodes
  • References to other ActiveMember360 custom shortcodes
  • Javascript
  • CSS
  • HTML
  • Text
  • PHP code ( using [mbr_exec] )