• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Search for "short code"

Search Results for: short code

wpmem_logged_in shortcode using wpmem_do_shortcode()

Chad Butler · Jan 28, 2019 ·

Continue Reading →

wpmem_form with redirect_to attribute using wpmem_do_shortcode()

Chad Butler · Jan 28, 2019 ·

Continue Reading →

wpmem_field shortcode using wpmem_do_shortcode()

Chad Butler · Jan 28, 2019 ·

Continue Reading →

wpmem_do_shortcode()

Chad Butler · Jan 28, 2019 ·

Continue Reading →

wpmem_do_shortcode()

Description

This function runs a shortcode's callback function directly without having to parse the full regex that do_shortcode() has to run. It can be used for any shortcode - not just WP-Members.

Parameters

$tag
(string) (required) The tag for the shortcode being run.

$atts
(array) (optional) Any attributes as an array.

$content
(string) (optional) Any nested content for the shortcode.

Usage

wpmem_do_shortcode( $tag, $atts, $content );

Examples

Here is an example where an attribute is included directly. The function arguments are the tag of the shortcode (in this case "wpmem_form") and an array of the attributes. This example is the same as using [wpmem_form first_name] to display the field value in "first_name":

echo wpmem_do_shortcode( 'wpmem_field', array( 'first_name' ) );


This is an example where there is an array key for the value. The example is the same as:
[wpmem_form login redirect_to="https://mysite.com/my-page/"]
Note that the order of arguments in the array is important. The "tag" needs to be the first attribute because the shortcode parser reads that in array key [0], so it must be first. If you set up your array values following the same order as you would for the shortcode you're calling, it will come out right.

$atts = array(
    'login',
    'redirect_to' => 'https://mysite.com/my-page/'
);
echo wpmem_do_shortcode( 'wpmem_form', $atts );


Here is an example of a shortcode with nested content. The example would be the same result as the following shortcode:
[wpmem_logged_in]This content only displays to a logged in user[/wpmem_logged_in]
If there were additional attributes for wpmem_logged_in then those would go in the array position. In this example, however, there are no attributes, so pass either null (as in the example) or an empty array.

$content = "This content only displays to a logged in user";
echo wpmem_do_shortcode( 'wpmem_logged_in', '', $content );

Notes

  • This utility can be used for any shortcode - not just WP-Members shortcodes.  The only requirement is that WP-Members is installed and active.
  • This utility comes from J.D. Grimes. You can implement his solution directly (if needed in an instance that WP-Members is not being used).

Changelog

  • Introduced in version 3.2.5

Source

wpmem_do_shortcode() is located in /includes/api/api-utilities.php.

  • « Go to Previous Page
  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Page 5
  • Interim pages omitted …
  • Page 52
  • Go to Next Page »

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy