Skip to main content

Custom Shortcodes Module

Overview

ActiveMember360 Custom Shortcodes are an extremely versatile and practical way to include repetitive content into your posts, pages, widgets, etc.

Within ActiveMember360 Custom Shortcodes you can include:

  • References to other ActiveMember360 standard shortcodes
  • References to WordPress and third-party shortcodes
  • References to other ActiveMember360 custom shortcodes
  • Javascript
  • CSS
  • HTML
  • Text
  • PHP using the ActiveMember360 shortcode [mbr_exec]

All this is possible due to the inherent capabilities of ActiveMember360's unique bespoke shortcode processor.

Whilst WordPress has always supported custom shortcodes it requires that they be defined in PHP. ActiveMember360 permits custom shortcodes to be defined using nothing more that the standard WordPress text editor.

ActiveMember360 Custom Shortcodes can be used in almost any situation and can be combined to create extremely powerful sets of repetitive, intelligent procedures.

Alternatively ActiveMember360 Custom Shortcodes can be used for simple reusable content snippets.

Over time, you can create your own library of ActiveMember360 Custom Shortcodes that can be used on any of your ActiveMember360 powered sites without having to constantly "re-invent the wheel" on every page, post, lesson, etc.

ActiveMember360 Custom Shortcodes are a WordPress custom post type.

Adding and managing ActiveMember360 Custom Shortcodes is done in exactly the same way as with any standard WordPress post/page.

ActiveMember360 Custom Shortcodes can be created, listed and managed from within the WordPress administrator main navigation.

Activation

Steps to activate Custom Shortcodes module
Steps to activate Custom Shortcodes module
  1. In WordPress administrator main navigation click ActiveMember360, Modules.
  2. In ActiveMember360 Modules tabs click Custom Shortcodes.
  3. Set Enable Custom Shortcodes module to Yes/On.
  4. Click Save Settings.

Once activated Cust. Shortcodes will be added to the WordPress administrator main navigation.

Workflow

Adding & Defining Custom Shortcodes

Steps to add a new custom shortcode
Steps to add a new custom shortcode
  1. To add a new custom shortcode click Add New in the WordPress administrator Custom Shortcodes listing.

  2. Specify a title for your custom shortcode. It is best to make this somewhat descriptive, or to your chosen naming convention, to aid selection when required.

  3. Define your required content for your custom shortcode.

  4. Define your Custom Shortcode Name.

    This should start with mbr_ and only contain lower case alphanumeric characters and underscores.

    Important

    If you do not provide a custom shortcode name one will be automatically created from the custom shortcode title upon saving the shortcode.

    It will be created using the criteria previously mentioned in that it should start with mbr_ and only contain lower case alphanumeric characters and underscores.

    As an example a title of Example Custom-Shortcode would be given the custom shortcode name of mbr_example_custom_shortcode.

    Once a custom shortcode name has been created it can only be changed by manually editing the custom shortcode name. It will not be changed by modifications to the custom shortcode title.

    ActiveMember360 will ensure that any custom shortcode name remains unique.

  5. Add any notes you wish to explain or detail the custom shortcode. These are for internal use only and are not displayed nor used elsewhere.

  6. Click Publish to make the custom shortcode active.

Referencing Custom Shortcodes

Custom shortcodes can be referenced in the same way as any other WordPress shortcode using the custom shortcode name and if relevant parameters. Please refer to Shortcodes using attributes (parameters).

Custom shortcodes can be used in the same locations as standard ActiveMember360 shortcodes so are resolved within:

  • The content of a Post, Page, or custom post type
  • The title of a Post, Page, or custom post type
  • Excerpts
  • WordPress Widgets
  • WordPress Menu items
  • WordPress Block Editor and many third party page builders

Passing & Referencing Parameters

ActiveMember360 provides the ability to pass parameters into custom shortcodes which can then be used within the custom shortcode or passed on into a nested shortcode/custom shortcode. These parameters enable you to use a custom shortcode to operate in a certain way based upon the parameter values passed to it.

The use of parameters with custom shortcodes is not compulsory.

Any parameter can be used with a custom shortcode. The parameter name does not have to be predefined.

Parameters are passed into the custom shortcode in the same way as standard shortcodes. Please refer to Shortcodes using attributes (parameters).

You reference the value of the parameter within the custom shortcode by using the construction %%parameter%%.

If a parameter is referenced using %%parameter%% in the custom shortcode definition but is not passed to the custom shortcode it will be replaced with an empty string.

Editing & Deleting Custom Shortcodes

Steps to manage custom shortcodes
Steps to manage custom shortcodes
  1. In WordPress administrator main navigation click Cust. Shortcodes.

  2. When you hover over a custom shortcode in the listing you will see the links to edit and trash (delete) the custom shortcode.

    Important

    If you delete or save as draft a custom shortcode the shortcode will remain present wherever it is referenced and display on the front end of your website as plain text.

    Please ensure that if you chose to delete a custom shortcode you also remove it from wherever it is used.

Examples

Assume we have a custom shortcode named mbr_alert that outputs a message in a specific format. The content and color of the message are passed using parameters.

The definition of the custom shortcode is:

<p style="color:%%color%%">The alert status is <span style="text-transform:uppercase">%%color%%</span>.</p>
<p><span style="color:%%color%%">%%content%%.</span></p>

So, on a post/page if we have:

[mbr_alert color='red' content='Please do not ignore this']

This outputs:

Custom Shortcodes Module Example 1 - Red

Whereas:

[mbr_alert color='green' content='All is working correctly']

Outputs:

Custom Shortcodes Module Example 1 - Green