• 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 » Filters » Remove an unparsed wpmem_txt shortcode

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?  

The best option is to not use plugins or themes that don’t reparse the $content with do_shortcode.  If the developer doesn’t know about this, then what other issues might be in their plugin or theme.  Work with plugins and themes that comply with WordPress APIs?

In some cases, that may not be a workable solution because the offending plugin may be something that you really want to use.  For those cases, we can apply a workaround.

When the login and registration form builder functions were rebuilt in 2.9, one addition was a set of defaults for the forms.  These defaults include mostly wrappers and some other elements (like text for buttons and some other things).  One of the wrappers is the wpmem_txt shortcode.  This is the txt_before and txt_after arguments for both the login and registration form.  The wpmem_login_form_args and wpmem_register_form_args filters can pass in an empty value for the wpmem_txt shortcode wrapper and that will remove the shortcode.  Since the handle is the same for both the login and register forms, you can use one function for both filters.

The code snippet below can be added to your theme’s functions.php file to filter out the unparsed shortcode:

add_filter( 'wpmem_login_form_args',    'remove_wpmem_txt_code' );
add_filter( 'wpmem_register_form_args', 'remove_wpmem_txt_code' );
function remove_wpmem_txt_code( $args ){
	$args = array(
		'txt_before' => '',
		'txt_after'  => ''
	);
	return $args;
}

One important note here is that filtering out the wpmem_txt shortcode is a workaround for an outside unsolved problem.  The better solution is to solve the problem.  Because the shortcode is unparsed, that means you may run into problems with form layout – not always, but it is a possibility.  The purpose of this shortcode is that it turns off wpautop and wptexturize for just WP-Members’ forms and replaces it with its own texturize filter.  This prevents WP from assuming that you want html formatted paragraphs and line breaks in your form (which is being delivered as content).

Filters, Tips and Tricks do_shortcode, free, str_replace, wpautop, wpmem_login_form_args, wpmem_register_form_args

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