can choose the email for registration, and wether to send one or not
This commit is contained in:
@@ -1,59 +1,116 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
function filter_email_wp_CIPF($args) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
error_log("---args: " . json_encode($args));
|
||||
return $args;
|
||||
}
|
||||
//add_filter('wp_mail', 'filter_email_wp_CIPF', 10, 1);
|
||||
|
||||
/*
|
||||
prof registration :
|
||||
{"to":"setrujegno@gufum.com","subject":"[La carte internationale des professeurs de fran\u00e7ais] Login Details","message":"Username: setrujegno\r\n\r\nTo set your password, visit the following address:\r\n\r\n<https:\/\/local-cipf-plugin.com\/?action=reset_password&key=1VB2c9x9IKrWqhlVFwlY&login=setrujegno>\r\n","headers":"","attachments":[]}
|
||||
|
||||
prof login :
|
||||
-nothing-
|
||||
|
||||
prof reset password :
|
||||
{"to":"setrujegno@gufum.com","subject":"[La carte internationale des professeurs de fran\u00e7ais] Password Reset","message":"Someone has requested a password reset for the following account:\r\n\r\nSite Name: La carte internationale des professeurs de fran\u00e7ais\r\n\r\nUsername: setrujegno\r\n\r\nIf this was a mistake, just ignore this email and nothing will happen.\r\n\r\nTo reset your password, visit the following address:\r\n\r\nhttps:\/\/local-cipf-plugin.com\/?action=reset_password&key=COiFnR4qJvyaSSky8FZt&login=setrujegno\r\n","headers":"","attachments":[]}
|
||||
|
||||
partenaire register :
|
||||
{"to":"justatodra@gufum.com","subject":"[La carte internationale des professeurs de fran\u00e7ais] Login Details","message":"Username: justatodra\r\n\r\nTo set your password, visit the following address:\r\n\r\n<https:\/\/local-cipf-plugin.com\/?action=reset_password&key=K3rT3VQ0vlQrVnicjTJ7&login=justatodra>\r\n","headers":"","attachments":[]}
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ../../../wordpress_docker/volumes/wp_volume/wp-includes/pluggable.php
|
||||
* 2210 : $send_notification_to_user = apply_filters( 'wp_send_new_user_notification_to_user', true, $user );
|
||||
*
|
||||
*/
|
||||
function send_registration_email_CIPF($send, $user) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$role_partner = PLGNTLS_class::ROLE_PARTNER;
|
||||
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||
|
||||
if (user_can($user, $role_prof)) {
|
||||
$send = is_email_registration_prof_CIPF();
|
||||
}
|
||||
else if (user_can($user, $role_partner)) {
|
||||
$send = is_email_registration_partner_CIPF();
|
||||
}
|
||||
|
||||
return $send;
|
||||
}
|
||||
add_filter( 'wp_send_new_user_notification_to_user', 'send_registration_email_CIPF', 10, 2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* use this filter to modify the message of the notification email
|
||||
* you can use the specials custer expansions as $$<field>$$
|
||||
* ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
|
||||
* 24 : add_filter( 'wp_new_user_notification_email', array( __CLASS__, 'newuser_notification_email' ), 20, 3 );
|
||||
*
|
||||
*/
|
||||
function filter_regitration_email_CIPF($wp_new_user_notification_email, $user, $blogname) {
|
||||
error_log("- wp_new_user_notification_email: ". json_encode($wp_new_user_notification_email));
|
||||
error_log("- user: ". json_encode($user));
|
||||
error_log("- blogname: ". json_encode($blogname));
|
||||
$wp_new_user_notification_email['message'] = 'poutpout $$nickname$$';
|
||||
PLGNTLS_class::debug_infos();
|
||||
$wp_new_user_notification_email['message'] = get_email_registration_CIPF();
|
||||
return $wp_new_user_notification_email;
|
||||
}
|
||||
//add_filter('wp_new_user_notification_email', 'filter_regitration_email_CIPF', 21, 3);
|
||||
add_filter('wp_new_user_notification_email', 'filter_regitration_email_CIPF', 21, 3);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
prof register :
|
||||
- wp_new_user_notification_email: {
|
||||
"to":"derzudospi@gufum.com",
|
||||
"subject":"[%s] Login Details",
|
||||
"message":"Username: derzudospi\r\n\r\nTo set your password, visit the following address:\r\n\r\nhttps:\/\/local-cipf-plugin.com\/wp-login.php?action=rp&key=NxtYeVuMfdQdcb1t2fD4&login=derzudospi\r\n\r\nhttps:\/\/local-cipf-plugin.com\/wp-login.php\r\n",
|
||||
"headers":""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function set_email_registration_CIPF($email, $is_email_prof, $is_email_partner) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$option_email = PLGNTLS_class::OPTION_EMAIL;
|
||||
|
||||
$option_data = array();
|
||||
$option_data['email'] = $email;
|
||||
$option_data['is_email_prof'] = $is_email_prof;
|
||||
$option_data['is_email_partner'] = $is_email_partner;
|
||||
|
||||
update_option($option_email['_name'], serialize($option_data), '', 'no');
|
||||
}
|
||||
- user: {
|
||||
"data":{"ID":"221","user_login":"derzudospi","user_pass":"$P$BqmuxKGayo4bNTaGasmrwn46mXP6gv.","user_nicename":"derzudospi","user_email":"derzudospi@gufum.com","user_url":"","user_registered":"2024-03-26 21:32:32","user_activation_key":"","user_status":"0","display_name":"derzudospi"},"ID":221,"caps":{"professeur__professeure":true},"cap_key":"wp_503463_capabilities","roles":["professeur__professeure"],"allcaps":{"unfiltered_html":true,"upload_files":true,"campaign_form_submit":true,"copy_posts":true,"delete_others_posts":true,"delete_posts":true,"delete_private_posts":true,"delete_published_posts":true,"edit_others_posts":true,"edit_posts":true,"edit_private_posts":true,"edit_published_posts":true,"manage_links":true,"publish_posts":true,"read_private_posts":true,"delete_others_pages":true,"delete_pages":true,"delete_private_pages":true,"delete_published_pages":true,"edit_others_pages":true,"edit_pages":true,"edit_private_pages":true,"edit_published_pages":true,"manage_categories":true,"publish_pages":true,"read_private_pages":true,"e2pdf":true,"e2pdf_templates":true,"e2pdf_settings":true,"e2pdf_license":true,"e2pdf_debug":true,"professeur__professeure":true},"filter":null}
|
||||
- blogname: "La carte internationale des professeurs de fran\u00e7ais"
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
function get_email_registration_option_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$option_email = PLGNTLS_class::OPTION_EMAIL;
|
||||
|
||||
$email_option_serialized = get_option($option_email['_name']);
|
||||
if (false === $email_option_serialized) {
|
||||
add_option($option_email['_name'], serialize($option_email['_default']), '', 'no');
|
||||
$email_option_serialized = get_option($option_email['_name']);
|
||||
}
|
||||
|
||||
return unserialize($email_option_serialized);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function get_email_registration_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$email_option = get_email_registration_option_CIPF();
|
||||
return $email_option['email'];
|
||||
}
|
||||
|
||||
function is_email_registration_prof_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$email_option = get_email_registration_option_CIPF();
|
||||
return $email_option['is_email_prof'];
|
||||
}
|
||||
function is_email_registration_partner_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$email_option = get_email_registration_option_CIPF();
|
||||
return $email_option['is_email_partner'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user