• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

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 » Plugins » WP-Members » Documentation » API Functions » wpmem_do_shortcode()

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

Example where an attribute is included directly:

// This will display the value of "first_name" for the current user.
echo wpmem_do_shortcode( 'wpmem_field', array( 'first_name' ) );

Example of an attribute that needs an array key:

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

Example of a shortcode with content:

$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.

  • Getting Started
  • Recommended WordPress® Settings
  • Plugin Settings
    • Options
    • Fields
    • Dialogs
    • Emails
    • New Feature Settings
  • Managing Content
    • Restricting Posts
    • Restricting Pages
    • Show Excerpts
    • Custom Post Types
  • Managing Users
    • Import Users
    • Export Users
    • Edit Users
    • Search Users
  • Login
  • Registration
    • Choosing Fields
    • Create a Registration Page
    • Moderating Registration
    • Using CAPTCHA
    • Removing Registration Options
  • User Profile
  • Membership Products
    • Membership Properties
    • Membership Levels
  • Menus
    • Individual Menu Items
    • Logged In Menus
    • Login/Logout Menu Link
  • Customizing Emails
    • Email Address
    • Email Content
    • Email Format
    • Email Shortcodes
    • Email Troubleshooting
  • Customizing Forms
    • Create a Custom Stylesheet
    • Using the WordPress Customizer
    • Login Form HTML
    • Registration Form HTML
    • Widget Login Form HTML
  • Translation and Localization
    • Maintain a custom translation file
    • Filter untranslated strings
    • Multi-language Considerations
  • Shortcodes
    • Pages and Forms
    • Login Status
    • User Fields
    • Email
    • Other Shortcodes
  • WP-CLI Commands
  • API Functions
  • Filter Hooks
  • Action Hooks
  • FAQs
    • Email troubleshooting
    • The plugin isn’t blocking my content
    • How can I prevent registration spam?
    • How to add a shortcode
    • How to apply login redirects
    • Are files protected?
    • Why can’t users log in?
    • Why does reCAPTCHA v3 fail?
    • Troubleshooting Really Simple Captcha
    • Why do I get a 403 error?
    • How do I use code snippets?
    • My changes aren’t showing up
    • How to hide the “Admin Bar”
    • How to add a forgot password link
    • Password reset doesn’t show any fields
    • There was an error processing the form
    • Hidden vs. Restricted
  • Demo Videos
  • How to Request Support
  • Copy Settings for Support
  • Hosting Recommendations

Ready to get started?

Join Today!

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

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