From 63cc1f28c0bcc7fb58dc637316114a6483a12b3f Mon Sep 17 00:00:00 2001 From: asus Date: Tue, 5 Mar 2024 00:10:53 +0100 Subject: [PATCH] created a new function to filter emails --- plugins/fipfcard_plugin/fipfcard_plugin.php | 147 +++++++++++++++++- ...it_acf_fields.php => reset_acf_fields.php} | 9 +- plugins/fipfcard_plugin/php/user_infos.php | 1 + private | 2 +- 4 files changed, 156 insertions(+), 3 deletions(-) rename plugins/fipfcard_plugin/php/{reinit_acf_fields.php => reset_acf_fields.php} (54%) diff --git a/plugins/fipfcard_plugin/fipfcard_plugin.php b/plugins/fipfcard_plugin/fipfcard_plugin.php index b277247..258d55e 100644 --- a/plugins/fipfcard_plugin/fipfcard_plugin.php +++ b/plugins/fipfcard_plugin/fipfcard_plugin.php @@ -43,7 +43,7 @@ include_once(PLGNTLS_class::get_path() . '/php/hide_admin.php'); include_once(PLGNTLS_class::get_path() . 'php/register_partenaires.php'); include_once(PLGNTLS_class::get_path() . 'php/redirections.php'); include_once(PLGNTLS_class::get_path() . 'php/author_restriction.php'); -include_once(PLGNTLS_class::get_path() . 'php/reinit_acf_fields.php'); +include_once(PLGNTLS_class::get_path() . 'php/reset_acf_fields.php'); //include_once(PLGNTLS_class::get_path() . 'php/form_builder_patch/url_validation.php'); include_once(PLGNTLS_class::get_path() . 'php/form_builder_patch/multiple_modals.php'); @@ -52,4 +52,149 @@ include_once(PLGNTLS_class::get_path() . 'php/form_builder_patch/multiple_modals + +/* +* old version +* callback for filter_email_CIPF, that does not receive the user id +*/ +function replace_words_CIPF($matches) { + $current_user = wp_get_current_user(); + $query = $matches[1]; + $result = $current_user->$query; + return $result; +} + +function filter_email_CIPF($reply_body, $post_array) { + $id = $post_array['ID']; + error_log("---"); + // pattern : anything surrounded by '$$', ex : $$value$$ + $pattern = '/\$\$(.*?)\$\$/'; + + // old version, using an outside callback, better readibility but cannot pass $id + //$new_body = preg_replace_callback($pattern, 'replace_words_CIPF', $reply_body); + + // inline callback, with 'use' to get the id + $new_body = preg_replace_callback($pattern, function($matches) use ($id) { + $current_user = get_user_by('id', $id); + $query = $matches[1]; + $result = $current_user->$query; + return $result; + }, $reply_body); + + error_log("new_body"); + error_log($new_body); + + return $new_body; +} +add_filter('df_confirmation_body', 'filter_email_CIPF', 10, 2); + +/* + +// Define your key-value pairs +$replacements = [ + 'name' => 'John', + 'value' => '100', +]; + +// Define a regular expression to match $$keywords$$ + +// Define a callback function to replace the keywords with values +$replacement_function = function ($matches) use ($replacements) { + // $matches[1] contains the keyword without the $$ signs + $keyword = $matches[1]; + // If the keyword exists in the replacements array, return its value + // Otherwise, return the original keyword (without the $$ signs) + return isset($replacements[$keyword]) ? $replacements[$keyword] : $matches[0]; +}; + +// Replace the keywords using preg_replace_callback() +$new_string = preg_replace_callback($pattern, $replacement_function, $string); + +// Output the new string + +*/ + + + +/* +priority : 1 +"Merci pour votre inscription." +{"ID":"24","user_login":"Hugogogo","user_pass":"$P$B1KLMir9WeEwvjmgJhQsT0o5ifXMUb.","user_nicename":"hugogogo","user_email":"hugogogo@protonmail.com","user_url":"","user_registered":"2024-02-19 10:55:38","user_activation_key":"","user_status":"0","display_name":"Hugogogo","field_title":["Pr\u00e9nom","Nom","Adresse","Adresse (compl\u00e9ment)","Code postal","Ville","Pays","T\u00e9l\u00e9phone","Adresse email","Fonction","\u00c9tablissement","Niveau d\u2019enseignement","10 ou 15 \u20ac ?","Nom de votre association","Pr\u00e9nom et nom du pr\u00e9sident","Adresse email de l\\'association pour la validation de votre statut","Obs","Photo d\\'identit\u00e9 pour la carte","Justificatif (ex : la copie de votre carte de travail)","Livraison","Moyen de paiement","Conditions g\u00e9n\u00e9rales de vente","Co\u00fbt"],"first_name":"Hugo","last_name":"lamy","user_meta":["de_fb_adresse_1","de_fb_adresse_2","de_fb_code_postal","de_fb_ville","de_fb_pays","de_fb_telephone","de_fb_fonction","de_fb_etablissement","de_fb_niveau_denseignement","de_fb_tarif","de_fb_nom_asso","de_fb_president_asso","de_fb_email_asso","de_fb_observations","de_fb_photo_du_profil","de_fb_justificatif","de_fb_livraison","de_fb_paiement","de_fb_cgv","de_fb_somme_a_regler"],"adresse_2":"","telephone":"","tarif_calc_value":"15","observations":"","livraison_calc_value":"0","somme_a_regler":""} + +priority : 10 +"Merci pour votre inscription." +{"ID":"24","user_login":"Hugogogo","user_pass":"$P$B1KLMir9WeEwvjmgJhQsT0o5ifXMUb.","user_nicename":"hugogogo","user_email":"hugogogo@protonmail.com","user_url":"","user_registered":"2024-02-19 10:55:38","user_activation_key":"","user_status":"0","display_name":"Hugogogo","field_title":["Pr\u00e9nom","Nom","Adresse","Adresse (compl\u00e9ment)","Code postal","Ville","Pays","T\u00e9l\u00e9phone","Adresse email","Fonction","\u00c9tablissement","Niveau d\u2019enseignement","10 ou 15 \u20ac ?","Nom de votre association","Pr\u00e9nom et nom du pr\u00e9sident","Adresse email de l\\'association pour la validation de votre statut","Obs","Photo d\\'identit\u00e9 pour la carte","Justificatif (ex : la copie de votre carte de travail)","Livraison","Moyen de paiement","Conditions g\u00e9n\u00e9rales de vente","Co\u00fbt"],"first_name":"Hugo","last_name":"lamy","user_meta":["de_fb_adresse_1","de_fb_adresse_2","de_fb_code_postal","de_fb_ville","de_fb_pays","de_fb_telephone","de_fb_fonction","de_fb_etablissement","de_fb_niveau_denseignement","de_fb_tarif","de_fb_nom_asso","de_fb_president_asso","de_fb_email_asso","de_fb_observations","de_fb_photo_du_profil","de_fb_justificatif","de_fb_livraison","de_fb_paiement","de_fb_cgv","de_fb_somme_a_regler"],"adresse_2":"","telephone":"","tarif_calc_value":"15","observations":"","livraison_calc_value":"0","somme_a_regler":""} + +priority : 20 +"Merci pour votre inscription." +{"ID":"24","user_login":"Hugogogo","user_pass":"$P$B1KLMir9WeEwvjmgJhQsT0o5ifXMUb.","user_nicename":"hugogogo","user_email":"hugogogo@protonmail.com","user_url":"","user_registered":"2024-02-19 10:55:38","user_activation_key":"","user_status":"0","display_name":"Hugogogo","field_title":["Pr\u00e9nom","Nom","Adresse","Adresse (compl\u00e9ment)","Code postal","Ville","Pays","T\u00e9l\u00e9phone","Adresse email","Fonction","\u00c9tablissement","Niveau d\u2019enseignement","10 ou 15 \u20ac ?","Nom de votre association","Pr\u00e9nom et nom du pr\u00e9sident","Adresse email de l\\'association pour la validation de votre statut","Obs","Photo d\\'identit\u00e9 pour la carte","Justificatif (ex : la copie de votre carte de travail)","Livraison","Moyen de paiement","Conditions g\u00e9n\u00e9rales de vente","Co\u00fbt"],"first_name":"Hugo","last_name":"lamy","user_meta":["de_fb_adresse_1","de_fb_adresse_2","de_fb_code_postal","de_fb_ville","de_fb_pays","de_fb_telephone","de_fb_fonction","de_fb_etablissement","de_fb_niveau_denseignement","de_fb_tarif","de_fb_nom_asso","de_fb_president_asso","de_fb_email_asso","de_fb_observations","de_fb_photo_du_profil","de_fb_justificatif","de_fb_livraison","de_fb_paiement","de_fb_cgv","de_fb_somme_a_regler"],"adresse_2":"","telephone":"","tarif_calc_value":"15","observations":"","livraison_calc_value":"0","somme_a_regler":""} + +priority : 999 +"Merci pour votre inscription." +{"ID":"24","user_login":"Hugogogo","user_pass":"$P$B1KLMir9WeEwvjmgJhQsT0o5ifXMUb.","user_nicename":"hugogogo","user_email":"hugogogo@protonmail.com","user_url":"","user_registered":"2024-02-19 10:55:38","user_activation_key":"","user_status":"0","display_name":"Hugogogo","field_title":["Pr\u00e9nom","Nom","Adresse","Adresse (compl\u00e9ment)","Code postal","Ville","Pays","T\u00e9l\u00e9phone","Adresse email","Fonction","\u00c9tablissement","Niveau d\u2019enseignement","10 ou 15 \u20ac ?","Nom de votre association","Pr\u00e9nom et nom du pr\u00e9sident","Adresse email de l\\'association pour la validation de votre statut","Obs","Photo d\\'identit\u00e9 pour la carte","Justificatif (ex : la copie de votre carte de travail)","Livraison","Moyen de paiement","Conditions g\u00e9n\u00e9rales de vente","Co\u00fbt"],"first_name":"Hugo","last_name":"lamy","user_meta":["de_fb_adresse_1","de_fb_adresse_2","de_fb_code_postal","de_fb_ville","de_fb_pays","de_fb_telephone","de_fb_fonction","de_fb_etablissement","de_fb_niveau_denseignement","de_fb_tarif","de_fb_nom_asso","de_fb_president_asso","de_fb_email_asso","de_fb_observations","de_fb_photo_du_profil","de_fb_justificatif","de_fb_livraison","de_fb_paiement","de_fb_cgv","de_fb_somme_a_regler"],"adresse_2":"","telephone":"","tarif_calc_value":"15","observations":"","livraison_calc_value":"0","somme_a_regler":""} + +*/ + + + +/* +add_filter( 'df_confirmation_body', 'filter_email_CIPF', 1); // 8-9-10-11 : body email to prof +add_filter( 'df_confirmation_body', 'filter_email_CIPF', 1); // 8-9-10-11 : body email to prof +add_filter( 'df_notification_body', 'filter_email_CIPF', 1); // 1 : body email to diego +add_filter( 'df_notifcation_recipient', 'filter_email_CIPF', 1); // 2 : email to: (to diego) +*/ + +/* +used : + + add_filter( 'df_confirmation_body', 'filter_email_CIPF', 1); // 8-9-10-11 + - "Merci pour votre inscription." + add_filter( 'df_confirmation_body', 'filter_email_CIPF', 1); // 8-9-10-11 + - "Merci pour votre inscription." + add_filter( 'df_confirmation_body', 'filter_email_CIPF', 1); // 8-9-10-11 + - "Merci pour votre inscription." + add_filter( 'df_notifcation_recipient', 'filter_email_CIPF', 1); // 2 + - "testi_le_testeur@proton.me" + add_filter( 'df_notification_body', 'filter_email_CIPF', 1); // 1 + - "Commande \u00e0 v\u00e9rifier sur le site :lamy, Hugo a command\u00e9 sa carte." + + +not used : +add_filter( 'df_contact_recipient', 'filter_email_CIPF', 1); // 6-7 +add_filter( 'df_contact_recipient', 'filter_email_CIPF', 1); // 6-7 +add_filter( 'df_contact_body', 'filter_email_CIPF', 1); // 4-5 +add_filter( 'df_contact_body', 'filter_email_CIPF', 1); // 4-5 +add_filter( 'wpml_translate_single_string', 'filter_email_CIPF', 1); // 3 +add_filter('df_contact_body', 'filter_email_CIPF', 1); // 0 +*/ + + + +/* + + +1 $body = apply_filters( 'df_notification_body', $body, $post_array ); +2 $email = apply_filters( 'df_notifcation_recipient', $email, $form_id, $post_array ); +3 $title = apply_filters( 'wpml_translate_single_string', $title_get, 'divi-form-builder', 'Edit Post Button Title Text' ); + +4 $body = apply_filters( 'df_contact_body', $body, $post_array ); +5 $body = apply_filters( 'df_contact_body', $body, $post_array ); + +6 $email = apply_filters( 'df_contact_recipient', $email, $form_id, $post_array ); +7 $email = apply_filters( 'df_contact_recipient', $email, $form_id, $processed_post_array ); + +8 $reply_body = apply_filters( 'df_confirmation_body', $reply_body, $post_array ); +9 $reply_body = apply_filters( 'df_confirmation_body', $reply_body, $post_array ); +10 $reply_body = apply_filters( 'df_confirmation_body', $reply_body, $post_array ); +11 $reply_body = apply_filters( 'df_confirmation_body', $reply_body, $post_array ); + +12 $message_content = apply_filters( 'the_content', get_post_field( 'post_content', $message_array['layout'] ) ); +13 $content = apply_filters( 'the_content', get_post_field( 'post_content', $message_array['layout'] ) ); +14 $content = apply_filters( 'the_content', get_post_field('post_content', $html_content_divi_layout)); + +*/ + + + + ?> diff --git a/plugins/fipfcard_plugin/php/reinit_acf_fields.php b/plugins/fipfcard_plugin/php/reset_acf_fields.php similarity index 54% rename from plugins/fipfcard_plugin/php/reinit_acf_fields.php rename to plugins/fipfcard_plugin/php/reset_acf_fields.php index cf7ef5e..ab35251 100644 --- a/plugins/fipfcard_plugin/php/reinit_acf_fields.php +++ b/plugins/fipfcard_plugin/php/reset_acf_fields.php @@ -1,12 +1,19 @@ diff --git a/plugins/fipfcard_plugin/php/user_infos.php b/plugins/fipfcard_plugin/php/user_infos.php index 9b23e3a..86b49ec 100644 --- a/plugins/fipfcard_plugin/php/user_infos.php +++ b/plugins/fipfcard_plugin/php/user_infos.php @@ -79,6 +79,7 @@ function current_user_infos_CIPF($atts) { $user_infos = merge_two_arrays_CIPF($user_metas, $user_properties); return output_list_front_CIPF($user_infos); } + // only return the first argument $query = $atts[0]; $output = $current_user->$query; if (is_string($output)) diff --git a/private b/private index 3ab9da9..c57d99e 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit 3ab9da9ec3d06436e6995f8688531b8a2f0ca198 +Subproject commit c57d99e92f456a9e64e89f85d98af3422bfcd202