Magic Login offers great flexibility when you add a magic login form to your site. You can easily customize the label using the block editor or even with a shortcode. But sometimes, you might want to change strings directly added to the plugin, such error messages and you might want to customize them too.
Here are the options to demonstrate how you can customize them.
Loco Translate #
Loco Translate is a great plugin that lets you manage your language catalog, making it easy to change the strings to display as you prefer.
Gettext Filter #
If you’re comfortable adding snippets, you can manipulate the strings using the gettext filter.
add_filter( 'gettext', 'change_magic_login_strings', 10, 3 );
function change_magic_login_strings( $translated_text, $untranslated_text, $domain ) {
if ( 'magic-login' !== $domain ) {
return $translated_text;
}
if ( 'Username or Email Address' === $untranslated_text ) {
$translated_text = 'Email Address';
}
if ( 'Please enter your username or email address. You will receive an email message to log in.' === $untranslated_text ) {
$translated_text = 'Please enter your email address. You will receive an email message to log in.'; // you can update the message
}
if ( 'Invalid magic login token. <a href="%s">Try signing in instead</a>?' === $untranslated_text ) {
$translated_text = 'Invalid magic login token, try to create <a href="%s">a new login link</a>?';
}
return $translated_text;
}