• Resolved Momo

    (@yangman)


    Hi.

    Is it possible to create the two-factor folder with the modified file in child theme to override the file in wp-content/plugins/two-factor?

    For example if I want to change the Error message when a wrong code is entered to say something else instead of ERROR: Invalid verification code.

    Thank you

Viewing 1 replies (of 1 total)
  • Plugin Author Kaspars

    (@kasparsd)

    Hi! Unfortunately, WordPress doesn’t offer this kind of functionality — only themes can have a child theme.

    You could use the gettext filter that is used by WordPress when returning translated strings. Please this in your child theme or utility plugin:

    add_filter( 'gettext', function( $translation, $text, $domain ) {
    	if ( 'two-factor' === $domain && 'ERROR: Invalid verification code.' === $text ) {
    		return 'YOUR CUSTOM ERROR MESSAGE';
    	}
    
    	return $translation;
    }, 10, 3 );

    Please note that this filter will run on every string output and can potentially impact the performance of your website. It will also disable translating that particular string during the output.

    • This reply was modified 5 years, 8 months ago by Kaspars. Reason: Added example of filter
Viewing 1 replies (of 1 total)
  • The topic ‘Override Plugin Files in Child Theme’ is closed to new replies.