• 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

WP-Members shortcode replacement

Chad Butler · Jun 17, 2016 ·

This article is provided free. Find out how you can get full access to premium content, including how-to articles and support forums, as well as priority email support and member exclusive plugin extensions..

 

As of WP-Members 3.1.2, all variations of the [wp-members] shortcode tag are obsolete and should be replaced with their updated equivalent.  Continue Reading →

wpmem_email_shortcodes

Description

Filters the email and some of the email settings.

Parameters

$shortcodes
(array) (required) An array of email shortcodes.

$tag
(string) (optional) The email being sent (newreg|newmod|appmod|repass|getuser).

$user_id
(int) (optional) The user ID.

// Default email shortcodes for user emails:

$shortcodes = array(
    'blogname'     => $arr['blogname'],
    'username'     => $arr['user_login'],
    'password'     => $password,
    'email'        => $arr['user_email'],
    'reglink'      => $arr['reg_link'],
    'members-area' => $arr['wpmem_msurl'],
    'user-profile' => $arr['wpmem_msurl'],
    'exp-type'     => $arr['exp_type'],
    'exp-data'     => $arr['exp_date'],
    'exp-date'     => $arr['exp_date'],
    'login'        => $arr['wpmem_login'],
    'register'     => $arr['wpmem_reg'],
);

/*
 * In addition to the above, any meta keys for fields 
 * in the WP-Members fields tab are included as shortcodes.
 * For example, if you have a field with a meta_key
 * of "my_special_field" there will be a shortcode for
 * [my_special_field]
 */
 
// Default email shortcodes for admin notification email:

$shortcodes = array(
    'blogname'      => $arr['blogname'],
    'username'      => $arr['user_login'],
    'email'         => $arr['user_email'],
    'reglink'       => $arr['reg_link'],
    'exp-type'      => $arr['exp_type'],
    'exp-data'      => $arr['exp_date'],
    'exp-date'      => $arr['exp_date'],
    'user-ip'       => $arr['user_ip'],
    'activate-user' => $arr['act_link'],
    'fields'        => $field_str,
);            

/*
 * Custom fields are included in this array, 
 * the same as user emails above.
 */

Usage

add_filter( 'wpmem_email_shortcodes', function ( $shortcodes, $tag, $user_id ) {
  
  // $tag is the email that is being handled.
  // possible tags are: newreg|newmod|appmod|repass|getuser
  
  // This will add a shortcode [my-custom-value] that would be replaced with "Here Is My Value".
  $shortcodes['my-custom-value'] = "Here Is My Value";
  
  // This is an example of a shortcode replaced with a user meta field (by user ID).
  $shortcodes['my-user-field-value'] = get_user_meta( $user_id, 'my_user_field', true );
  
  return $shortcodes;
  
}, 10, 3 );

Changelog

  • Introduced in version 3.1.0
  • 3.4.2 added user ID

Source

wpmem_email_shortcodes is located in includes/class-wp-members-email.php.

Form Shortcodes

Shortcodes are available directly in the post editor window from the item in the toolbar menu: [ wp-members ]

wpmem_form

This shortcode can display various WP-Members forms by adding the following tags:

  • login – the main body login form
  • register – the registration form
  • password – forgot password reset and password change (dependent upon user login state)
  • user_edit – user profile edit
  • redirect_to – accepts a url to redirect to upon successful form action (login|register forms only).

For example, to display a login form, the shortcode would be as follows:

[wpmem_form login /]

The login and register forms each have a default logged in state that displays some bullet links. These links can be customized with the wpmem_login_links_args, wpmem_login_link, wpmem_register_links_args, and wpmem_register_links filters.  You can override the default logged in state with your own content by nesting it in the shortcode as follows:

[wpmem_form login]
This only displays to a logged in user.
You are logged in as: [wpmem_field field=user_login]
[wpmem_logout]
[/wpmem_form]

Anything nested between the [wpmem_form] tags will be what shows to the logged in user.

Both the login and register forms also accept a redirect_to parameter.  This allows you to manually set a page that the form will redirect to upon successful submission.  (Note that this can also be done with the wpmem_login_redirect and wpmem_register_redirect filters.)

Note: if you are considering a redirect, carefully consider whether it is truly necessary.  The plugin already has a default flow that is designed to offer a smooth user experience.

Here is an example of a login form that will redirect the user to a specific page after successfully logging in:

[wpmem_form login redirect_to="http://mysite.com/my-special-page" /]

Note that the user_edit parameter should only be displayed to users who are logged in.  You can do this by nesting it in the logged in shortcode. Here is an example:

[wpmem_logged_in]
[wpmem_form user_edit]
[/wpmem_logged_in]
[wpmem_logged_out]
Log in to edit your profile[wpmem_form login]
[/wpmem_logged_out]

Other Shortcodes

On final evaluation of the new form fields filter, the hook name has been changed to wpmem_fields. Anyone using the above script that has it as wpmem_form_fields should change it to wpmem_fields when you update to 3.1.7 final release (or beta release candidate RC 3).

wpmem_logout

This shortcode displays a logout link wherever you want it.

[wpmem_logout]

By default, the link text will be “Click here to logout.”  If you want custom text, nest it in the shortcode:

[wpmem_logout]My Custom Log Out Text[/wpmem_logout]

wpmem_loginout

This shortcode displays a login/logout link, depending on the user’s login state.  Note: this shortcode requires that a login page location be set in the plugin’s main options.

[wpmem_loginout]

Default text for the links is “log in” and “log out”.  These can be changed with the following attributes (3.1.5+):

[wpmem_loginout login_text="Sign In" logout_text="Sign Out"]

Note: both text attributes are optional. You can use one or the other, both, or neither.

There is also a redirect attribute for login (3.1.5+):

[wpmem_loginout login_redirect_to="http://mysite.com/my-page/"]

wpmem_show_count

This shortcode displays a count of users. It can be used to display a total count of users on the site, users by role, or users by the value of a meta key.

Show a total count of site users (includes all roles) (3.1.5+):

[wpmem_show_count]

Number of Site Users: [wpmem_show_count]

Show a count of users for a particular role (3.1.5+):

[wpmem_show_count role="role_slug"]

Show a count of users for a given meta key:

[wpmem_show_count key="some_key" value="some_value"]

Include an optional label in the shortcode:

[wpmem_show_count label="Total Users:"]

[wpmem_show_count role="subscribers" label="Total Subscribers:"]

[wpmem_show_count key="active" value="1" label="Total Active Users:"]

wpmem_avatar

This shortcode can be used to display a user’s avatar image.  NOTE: WP uses gravatar by default.

To show a user avatar that defaults to the current user:

[wpmem_avatar]

To show an avatar for a specific user, pass the user’s email or ID using the “id” attribute:

[wpmem_avatar id=someuser@example.com]

[wpmem_avatar id=123]

wpmem_login_link & wpmem_reg_link

This shortcode generates a link to the login page or register page (if one is set in the main options).

[wpmem_login_link]

[wpmem_reg_link]

The default text for the link will be either “Log In” or “Register” (depending on the shortcode used).  Both shortcodes allow you to customize the text by nesting the content:

[wpmem_login_link]Log In Here[/wpmem_login_link]

[wpmem_reg_link]You may register here[/wpmem_reg_link]

Both links provide a redirect URL to the original page (the page the link was on).

Remove an unparsed wpmem_txt shortcode

Chad Butler · Apr 11, 2013 ·

This article is provided free. Find out how you can get full access to premium content, including how-to articles and support forums, as well as priority email support and member exclusive plugin extensions..

 

The wpmem_txt shortcode is something that WP-Members puts in on the fly and its purpose is to prevent WordPress from putting line breaks (<p> and <br /> via the wpautop and wptexturize functions) into the form, thus throwing off the layout.  This is one of those magic things that runs in the background that no one really knows about unless something breaks it.

Here is the problem: WordPress runs the shortcode parser on the content only once.  By itself, that’s not a problem.  However, if a plugin or theme developer includes a shortcode in their code and they do not use the function do_shortcode() on the $content variable before returning it, any shortcodes that are executed after theirs will be unparsed. For WP-Members, a bad practice like that will result in leaving wpmem_txt unparsed in your form.

So… how do you fix this?  Continue Reading →

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 4
  • Page 5
  • Page 6
  • Page 7
  • Page 8
  • 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