WordPress.org

Ready to get started?Download WordPress

Forums

WP-Members
[resolved] "[wpmem_txt]" text appears when outputting login page in template file (8 posts)

  1. Hassan
    Member
    Posted 1 year ago #

    Greetings,

    First, 'tis teh most awesomest membership plugin!

    Second, I'm using the shortcode [wp-members page="login"] to output the login form in my header.php template file like this:

    <?php echo do_shortcode('[wp-members page="login"]'); ?>

    The login form comes up and it's working fine, however, it is preceded with the text [wpmem_txt] and then followed with the text [/wpmem_txt] after the end of the form.

    What is this text? And how to get rid of it?

    http://wordpress.org/extend/plugins/wp-members/

  2. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    Glad you like the plugin.

    What you are seeing is a shortcode that the plugin puts in on the fly to overcome the WP's wpautop function. wpautop is what puts <p> tags into the $content variable, and that screws things up with the form layout.

    Some people like to shut this function off, where in other cases shutting it off would screw things up for the rest of the layout. So the plugin puts in an on-the-fly shortcode to shut wpautop off only for itself in the forms that go in the $content variable.

    Since the "page" parameters of the wp-members shortcode were intended for use as a page, your results may vary when used outside of that scope (like using it in the header).

    While I may put in some kind of a hook later on to eliminate the texturize shortcode down the road, at this time you don't really have a way to get that shortcode to parse if you are calling the shortcode directly.

    Your solution is probably to use the wpmem_login_form filter to filter out the shortcode elements.

  3. Hassan
    Member
    Posted 1 year ago #

    Chad, thanks for such an informative response.

    I haven't just figured out the "issue", I actually learned something new in the process --> wpautop :)

    So, using my not-so-super PHP skills I was able to come up with this code to use in my functions.php file, based on your suggestion:

    // Remove the opening [wpmem_txt] from login form
    function remove_open_wpmem_txt( $form ) {
    	$form = str_replace( '[wpmem_txt]', '', $form );
    	return $form;
    }
    add_filter( 'wpmem_login_form', 'remove_open_wpmem_txt' );
    
    // Remove the closing [/wpmem_txt] from login form
    function remove_close_wpmem_txt( $form ) {
    	$form = str_replace( '[/wpmem_txt]', '', $form );
    	return $form;
    }
    add_filter( 'wpmem_login_form', 'remove_close_wpmem_txt' );

    ...which does the job, but I have a feeling it could be done in a better way maybe? Please DO tell if this code can be improved/enhanced.

    Thank you.

  4. Hassan
    Member
    Posted 1 year ago #

    OFF-TOPIC:

    In the plugin's css folder there is the file (wp-members-2012.css). In the beginning, specifically at line 4, there is this comment:

    "CSS for the WP-Members plugin using TwentyEleven Theme"

    I believe that should've been "CSS for the WP-Members plugin using TwentyTwelve Theme"?

    A Copy-paste-forgot-to-change typo? :)

  5. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    You are definitely on the right track. You don't need two filters, though. You could do str_replace twice in one, or you could do it once with an array:

    $arr = array( '[wpmem_txt]', [/wpmem_txt]' );
    $form = str_replace( $arr, '', $form );

    or

    $form = str_replace( array( '[wpmem_txt]', [/wpmem_txt]' ), '', $form );

    (I think the Twenty Twelve stylesheet was probably built from the Twenty Eleven and the header didn't get updated.)

  6. Hassan
    Member
    Posted 1 year ago #

    Thanks, Chad. I was sure I could do it with an array.

    ...and by the way you forgot a single quote in each of the two examples you provided above.

    This:

    $arr = array( '[wpmem_txt]', [/wpmem_txt]' );

    ...should be:

    $arr = array( '[wpmem_txt]', '[/wpmem_txt]' );

    And this:

    $form = str_replace( array( '[wpmem_txt]', [/wpmem_txt]' ), '', $form );

    ...should be:

    $form = str_replace( array( '[wpmem_txt]', '[/wpmem_txt]' ), '', $form );

    Just in case someone else was trying to use it and got an error.

  7. adobedog1
    Member
    Posted 1 year ago #

    I've try most of the code snippets on this page and none of them seem to work. I added them to the functions page and the template page Specific to the problem and nothing happens same old [wpmem_txt]... any thoughts?

  8. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    Here's a more thorough explanation of the issue and solution:
    http://rocketgeek.com/filter-hooks/remove-an-unparsed-wpmem_txt-shortcode/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic