Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created April 16, 2024 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/083768a4f30ca650b48e931c95829945 to your computer and use it in GitHub Desktop.
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.
<?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