Support » Plugin: Say what? » Replacing String Not Working

  • Resolved toad78

    (@toad78)


    This plugin was recommended from this post. I guess I’m not completely understanding the purpose of this plugin, as I cannot replace a simple string.

    Within the user.php file, I need to override this:

    /* translators: %s: email address */
    __( '<strong>ERROR</strong>: The password you entered for the email address %s is incorrect.' ),

    to say this:
    ERROR: Your email and password did not match. Please try again.

    Pretty simple, right?

    Here are my settings:

    Original string:
    The password you entered for the email address %s is incorrect.

    Text domain
    Don’t see one

    Text context:
    I did put the full web domain here

    Replacement string:
    Your email and password did not match. Please try again.

    Thank you.

    • This topic was modified 3 months, 3 weeks ago by  toad78.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Lee Willis

    (@leewillis77)

    You can’t do partial matches like that. The “Original String” should be set to the full, original string as it appears in the source code.

    So, for the example you gave:

    <strong>ERROR</strong>: The password you entered for the email address %s is incorrect.

    In your example, text-domain and context should be blank. I’d recommend reading this article explaining what those relate to: https://plugins.leewillis.co.uk/doc_post/replacing-wordpress-strings-context/

    • This reply was modified 3 months, 3 weeks ago by  Lee Willis.
    • This reply was modified 3 months, 3 weeks ago by  Lee Willis.

    Well I guess I don’t understand how this plugin would work for me then. The below check content string is what I want to modify. In this case, as you mentioned above, I would leave both the Text domain and the Text context blank. But then I’m left with the conundrum of figuring out how to convert the string in the manner that’s it written because it is using the ‘%s’ variable. Or am I going to need to create a string function override in the functions.php?

    if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) ) {
    		return new WP_Error(
    			'incorrect_password',
    			sprintf(
    				/* translators: %s: user name */
    				__( '<strong>ERROR</strong>: The password you entered for the username %s is incorrect.' ),
    				'<strong>' . $username . '</strong>'
    			)......
    Plugin Author Lee Willis

    (@leewillis77)

    Just leave %s out of your replacement string of you don’t want it in there?

    I’ve already tried a variety:

    ERROR: The password you entered for the username %s is incorrect.’

    TO

    ERROR: Your email and password don’t match. Please try again.’

    but the WordPress default keeps posting instead of the override I’m attempting to use.

    Plugin Author Lee Willis

    (@leewillis77)

    I’ve just tried setting up a replacement for that string on a fresh WordPress install and it all works as I’d expect:

    https://www.dropbox.com/s/y77cc8lo1kda4t4/Screenshot%202019-07-25%2021.40.59.png?dl=0

    https://www.dropbox.com/s/twtbzih0hpero9e/Screenshot%202019-07-25%2021.40.09.png?dl=0

    [I used the Pro version to discover the string so the screenshots may look slightly different to yours, but the replacement will work fine with the free version]

    Yes, that’s exactly what I entered into the settings. But I’m still getting a default response.

    Plugin Author Lee Willis

    (@leewillis77)

    In which case that’s probably not the string being used (I notice your screenshot isn’t the default WordPress login page?).

    It’s possibly coming from another plugin, theme, or customisation somewhere, so might have different settings.

    This is using WooCommerce and WooCommerce does use WordPress default ‘user.php’ responses, which is the code I’ve supplied in the screenshots.

    Plugin Author Lee Willis

    (@leewillis77)

    Sorry to hear that. It definitely works for me here so I’m 99% sure it’s not a fault with the plugin, more likely an issue with the way you’ve got things set up, or a conflict with some plugin or theme code.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.