Created
April 16, 2024 06:53
-
-
Save andrewlimaza/083768a4f30ca650b48e931c95829945 to your computer and use it in GitHub Desktop.
Replace wp-login.php in WordPress emails to a custom login page via it's slug/permalink.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replace wp-login.php with a custom slug in all WordPress emails where it's generated. | |
* Add this code to a custom plugin or a child theme's functions.php | |
*/ | |
function my_replace_wp_login_in_emails($args) { | |
// Check if the message contains 'wp-login.php' | |
if (strpos($args['message'], 'wp-login.php') !== false) { | |
// Replace 'wp-login.php' with 'my-login' | |
$args['message'] = str_replace('wp-login.php', 'my-login', $args['message']); // change my-login to the slug of your choice | |
} | |
return $args; | |
} | |
add_filter( 'wp_mail', 'my_replace_wp_login_in_emails' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment