can choose the email for registration, and wether to send one or not

This commit is contained in:
asus
2024-03-27 13:06:48 +01:00
parent 0808c83589
commit ab6d825724
11 changed files with 384 additions and 140 deletions

View File

@@ -4,7 +4,7 @@ Plugin Name: custer_plugin
Plugin URI:
Description: customize user : output infos on page, on email, and change current user id momentarly
Author: hugogogo
Version: 0.1.6
Version: 0.1.7
Author URI:
*/

View File

@@ -89,7 +89,6 @@ function replace_words($matches, $user_id = null) {
function filter_email_wp($args) {
// pattern : anything surrounded by '$$', ex : $$value$$
$pattern = '/\$\$(.*?)\$\$/';
error_log("args: " . json_encode($args));
$old_body = $args['message'];
$new_body = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_body);
@@ -100,6 +99,24 @@ error_log("args: " . json_encode($args));
add_filter('wp_mail', __NAMESPACE__.'\filter_email_wp', 10, 1);
/*
* add this filter specifically for the new users, since otherwise we would not have their id
*
*/
function filter_regitration_email_CIPF($wp_new_user_notification_email, $user, $blogname) {
$user_id = $user->ID;
$pattern = '/\$\$(.*?)\$\$/';
$old_body = $wp_new_user_notification_email['message'];
$new_body = preg_replace_callback($pattern, function($matches) use ($user_id) {
return \CUSTER\replace_words($matches, $user_id);
}, $old_body);
$wp_new_user_notification_email['message'] = $new_body;
return $wp_new_user_notification_email;
}
add_filter('wp_new_user_notification_email', __NAMESPACE__.'\filter_regitration_email_CIPF', 22, 3);
?>

View File

@@ -33,9 +33,6 @@ function return_result($output) {
* if is acf, use acf default format
*/
function format_user_info($query, $current_user, $user_id) {
error_log("query: " . json_encode($query));
error_log("current_user: " . json_encode($current_user));
error_log("user_id: " . json_encode($user_id));
$output_date_format = Custer::USER_INFO_DATE_FORMAT;
$is_acf = false;