Skip to content

Instantly share code, notes, and snippets.

@mustafauysal
Created November 29, 2022 20:14
Show Gist options
  • Save mustafauysal/f0a25fea812ebf4846dfb1069cfbb5d2 to your computer and use it in GitHub Desktop.
Save mustafauysal/f0a25fea812ebf4846dfb1069cfbb5d2 to your computer and use it in GitHub Desktop.
Change magic login strings
<?php
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
}
return $translated_text;
}
@mustafauysal
Copy link
Author


    if ( $untranslated_text === 'Invalid magic login token, but you are logged in as \'%1$s\'. <a href="%2$s">Go to the dashboard instead</a>?' ) {
        // Change the message to your desired text
        $translated_text = sprintf( __( 'Your magic login token is not valid, but you are logged in as \'%1$s\'. <a href="%2$s">Would you like to go to the dashboard instead?</a>', 'magic-login' ), wp_get_current_user()->user_login, admin_url() );
    }
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment