- update date when transfert success
- role partner at creation ok
This commit is contained in:
asus
2024-03-22 19:10:35 +01:00
parent cb9042a746
commit 1fe5379845
4 changed files with 219 additions and 7 deletions

View File

@@ -46,14 +46,223 @@ if (!defined('ABSPATH')) {
//}
//add_filter('xoo_el_register_fields', 'check_fields_CIPF');
function test_add_fields_register_CIPF($args) {
error_log("args : " . json_encode($args));
echo '<input type="hidden" name="_test_hugo" value="test_hugo">';
/*
* hook to add a field in the xootix form
* 30 : ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/templates/global/xoo-el-register-section.php
*
*/
function add_fields_register_CIPF($args) {
PLGNTLS_class::debug_infos();
// error_log("args : " . json_encode($args));
$role_partner = PLGNTLS_class::ROLE_PARTNER;
$slug_partner_registration = PLGNTLS_class::SLUG_PARTNER_REGISTRATION;
$input_hidden_role = PLGNTLS_class::INPUT_HIDDEN_ROLE;
/*
* compare current slug to partner-register slug
* if it match, add a hidden field
*
*/
global $wp;
$current_slug = $wp->request;
if ($current_slug === $slug_partner_registration) {
echo "<input type='hidden' name='$input_hidden_role' value='$role_partner'>";
}
}
add_action( 'xoo_el_register_add_fields', 'test_add_fields_register_CIPF' );
add_action('xoo_el_register_add_fields', 'add_fields_register_CIPF');
/*
* filter to modify user before xootix create new user
* 437 : ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
*
* at registration, if form query is for partner
* -> change role to 'partenaire'
*
*/
function add_partenaires_CIPF($customer_data){
PLGNTLS_class::debug_infos();
$role_partner = PLGNTLS_class::ROLE_PARTNER;
$input_hidden_role = PLGNTLS_class::INPUT_HIDDEN_ROLE;
/*
* check query of form submit
* if contains parner, change role for partner
*
*/
if (!isset($_POST[$input_hidden_role])) {
error_log("not set _POST[input_hidden_role]");
return;
}
if ($_POST[$input_hidden_role] === $role_partner) {
error_log("_POST[input_hidden_role] === partner");
$customer_data['role'] = $role_partner;
}
return $customer_data;
}
add_filter('xoo_el_register_new_customer_data', 'add_partenaires_CIPF', 10, 1);
/*
profs :
wp: {
"public_query_vars":{"0":"m","1":"p","2":"posts","3":"w","4":"cat","5":"withcomments","6":"withoutcomments","7":"s","8":"search","9":"exact","10":"sentence","11":"calendar","12":"page","13":"paged","14":"more","15":"tb","16":"pb","17":"author","18":"order","19":"orderby","20":"year","21":"monthnum","22":"day","23":"hour","24":"minute","25":"second","26":"name","27":"category_name","28":"tag","29":"feed","30":"author_name","31":"pagename","32":"page_id","33":"error","34":"attachment","35":"attachment_id","36":"subpost","37":"subpost_id","38":"preview","39":"robots","40":"favicon","41":"taxonomy","42":"term","43":"cpage","44":"post_type","45":"embed","46":"post_format","47":"layout_category","48":"layout_tag","49":"layout_pack","50":"layout_type","51":"module_width","52":"scope","53":"et_tb_item_type","57":"rest_route","58":"sitemap","59":"sitemap-subtype","60":"sitemap-stylesheet","61":"et_code_snippet_type"},
"private_query_vars":["offset","posts_per_page","posts_per_archive_page","showposts","nopaging","post_type","post_status","category__in","category__not_in","category__and","tag__in","tag__not_in","tag__and","tag_slug__in","tag_slug__and","tag_id","post_mime_type","perm","comments_per_page","post__in","post__not_in","post_parent","post_parent__in","post_parent__not_in","title","fields"],
"extra_query_vars":[],
"query_vars":[],
"query_string":"",
"request":"",
"matched_rule":"",
"matched_query":"",
"did_permalink":false
}
_POST: {
"xoo_el_reg_username":"beknomakka",
"xoo_el_reg_email":"beknomakka@gufum.com",
"xoo_el_reg_pass":"pouetpouet",
"_xoo_el_form":"register",
"xoo_el_redirect":"\/redirection_cipf",
"action":"xoo_el_form_action",
"display":"inline"
}
partners :
wp: {"public_query_vars":{"0":"m","1":"p","2":"posts","3":"w","4":"cat","5":"withcomments","6":"withoutcomments","7":"s","8":"search","9":"exact","10":"sentence","11":"calendar","12":"page","13":"paged","14":"more","15":"tb","16":"pb","17":"author","18":"order","19":"orderby","20":"year","21":"monthnum","22":"day","23":"hour","24":"minute","25":"second","26":"name","27":"category_name","28":"tag","29":"feed","30":"author_name","31":"pagename","32":"page_id","33":"error","34":"attachment","35":"attachment_id","36":"subpost","37":"subpost_id","38":"preview","39":"robots","40":"favicon","41":"taxonomy","42":"term","43":"cpage","44":"post_type","45":"embed","46":"post_format","47":"layout_category","48":"layout_tag","49":"layout_pack","50":"layout_type","51":"module_width","52":"scope","53":"et_tb_item_type","57":"rest_route","58":"sitemap","59":"sitemap-subtype","60":"sitemap-stylesheet","61":"et_code_snippet_type"},"private_query_vars":["offset","posts_per_page","posts_per_archive_page","showposts","nopaging","post_type","post_status","category__in","category__not_in","category__and","tag__in","tag__not_in","tag__and","tag_slug__in","tag_slug__and","tag_id","post_mime_type","perm","comments_per_page","post__in","post__not_in","post_parent","post_parent__in","post_parent__not_in","title","fields"],"extra_query_vars":[],"query_vars":[],"query_string":"","request":"","matched_rule":"","matched_query":"","did_permalink":false}
_POST: {
"xoo_el_reg_username":"jardozespi",
"xoo_el_reg_email":"jardozespi@gufum.com",
"xoo_el_reg_pass":"pouetpouet",
"_xoo_el_form":"register",
"cipf_user_role":"partenaire",
"xoo_el_redirect":"\/redirection_cipf",
"action":"xoo_el_form_action",
"display":"inline"
}
*/
/*
*
* ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
*
*/
//function check_created_user_CIPF($customer_id, $new_customer_data) {
// error_log("--- in check_created_user_CIPF");
// error_log("customer_id: " . json_encode($customer_id));
// error_log("new_customer_data: " . json_encode($new_customer_data));
// $user_metas = get_user_meta($customer_id);
// error_log("user metas: " . json_encode($user_metas));
//}
//add_action('xoo_el_created_customer', 'check_created_user_CIPF', 10, 2);
//function temp_test_data_cipf($extra_data) {
// PLGNTLS_class::debug_infos();
// $input_hidden_role = PLGNTLS_class::INPUT_HIDDEN_ROLE;
//
// error_log("- in temp_test_data_cipf, extra data: " . json_encode($extra_data));
// $extra_data[$input_hidden_role] = '';
// error_log("- after, extra data: " . json_encode($extra_data));
// return $extra_data;
//}
//add_filter('xoo_aff_easy-login-woocommerce_data', 'temp_test_data_cipf');
/*
steps :
- ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
- 257 : function process_registration()
- 273 : get_fields_data() -> reg_admin_fields: {"xoo_el_reg_fname":{"field_type":"xoo_el_reg_fname","input_type":"text","settings":{"required":"yes","label":"","cols":"onehalf","icon":"far fa-user","placeholder":"First Name","minlength":"","maxlength":"","class":"","active":"no","unique_id":"xoo_el_reg_fname"},"priority":"10"},"xoo_el_reg_lname":{"field_type":"xoo_el_reg_lname","input_type":"text","settings":{"required":"yes","label":"","cols":"onehalf","icon":"far fa-user","placeholder":"Last Name","minlength":"","maxlength":"","class":"","active":"no","unique_id":"xoo_el_reg_lname"},"priority":"20"},"xoo_el_reg_username":{"field_type":"xoo_el_reg_username","input_type":"text","settings":{"active":"yes","label":"Cr\u00e9er votre identifiant","cols":"one","icon":"fas fa-user-plus","placeholder":"","minlength":"3","maxlength":"20","class":"","unique_id":"xoo_el_reg_username","required":"yes"},"priority":"30"},"xoo_el_reg_email":{"field_type":"xoo_el_reg_email","input_type":"email","settings":{"active":"yes","required":"yes","label":"Votre adresse mail","cols":"one","icon":"fas fa-at","placeholder":"","class":"","unique_id":"xoo_el_reg_email"},"priority":"40"},"xoo_el_reg_pass":{"field_type":"xoo_el_reg_pass","input_type":"password","settings":{"active":"yes","label":"Cr\u00e9ez votre mot de passe","cols":"one","icon":"fas fa-key","placeholder":"8 caract\u00e8res minimum","minlength":"8","maxlength":"100","password_visibility":"yes","class":"","unique_id":"xoo_el_reg_pass","required":"yes"},"priority":"50"},"xoo_el_reg_pass_again":{"field_type":"xoo_el_reg_pass_again","input_type":"password","settings":{"label":"","cols":"one","icon":"fas fa-key","placeholder":"Confirm Password","password_visibility":"yes","class":"","active":"no","unique_id":"xoo_el_reg_pass_again","required":"yes"},"priority":"60"},"xoo_el_reg_terms":{"field_type":"xoo_el_reg_terms","input_type":"checkbox_single","settings":{"required":"yes","label":"","placeholder":"The Terms and Conditions","cols":"one","checkbox_single":{"yes":{"checked":"","label":"I accept the <a href=\"privacy-policy\" target=\"_blank\"> Terms of Service and Privacy Policy <\/a>","value":"yes","priority":"10"}},"class":"","active":"no","unique_id":"xoo_el_reg_terms"},"priority":"70"},"xoo-el-username":{"field_type":"xoo-el-username","input_type":"text","settings":{"label":"Identifiant ou email","cols":"one","icon":"fas fa-user-plus","placeholder":"","class":"","unique_id":"xoo-el-username","required":"yes","active":"yes","elType":"login","custom_attributes":{"autocomplete":"username"}},"priority":"80"},"xoo-el-password":{"field_type":"xoo-el-password","input_type":"password","settings":{"label":"Mot de passe","cols":"one","icon":"fas fa-key","placeholder":"","password_visibility":"yes","class":"","unique_id":"xoo-el-password","required":"yes","elType":"login","custom_attributes":{"autocomplete":"current-password"}},"priority":"90"},"xoo-el-rp-pass":{"field_type":"xoo-el-rp-pass","input_type":"password","settings":{"label":"","cols":"one","icon":"fas fa-key","placeholder":"Nouveau mot de passe","minlength":"6","maxlength":"20","password_visibility":"yes","class":"","unique_id":"xoo-el-rp-pass","required":"yes","elType":"resetpw"},"priority":"100"},"xoo-el-rp-pass-again":{"field_type":"xoo-el-rp-pass-again","input_type":"password","settings":{"required":"yes","unique_id":"xoo-el-rp-pass-again","elType":"resetpw","label":"","cols":"one","icon":"fas fa-key","placeholder":"Confirmer le mot de passe","password_visibility":"yes","class":""},"priority":"110"},"user_login":{"field_type":"user_login","input_type":"text","settings":{"label":"","cols":"one","icon":"fas fa-user-plus","placeholder":"Identifiant\/e-mail","class":"","unique_id":"user_login","required":"yes","active":"yes","elType":"lostpw"},"priority":"120"},"xoo-el-sing-user":{"field_type":"xoo-el-sing-user","input_type":"text","settings":{"unique_id":"xoo-el-sing-user","required":"yes","active":"yes","elType":"single","custom_attributes":{"autocomplete":"username"},"xoo_el_username":"yes","label":"","cols":"one","icon":"fas fa-user-plus","placeholder":"Identifiant\/e-mail","class":""},"priority":990}}
- ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/xoo-form-fields-fw/admin/class-xoo-aff-fields.php
- 39 : public function get_fields_data( $format = 'array' )
-> 47 : return apply_filters( 'xoo_aff_'.$this->plugin_slug.'_data', $data );
- 275 : $doNotValidateOtherFields = get_fields('register') -> doNotValidateOtherFields: ["xoo-el-username","xoo-el-password","xoo-el-rp-pass","xoo-el-rp-pass-again","user_login","xoo-el-sing-user"]
- ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-fields.php
- 28 : public function get_fields( $type = 'register' )
-> 58 : return apply_filters( 'xoo_el_'.$type.'_fields', $fields );
- 277 : $fieldValues = validate_submitted_field_values( $_POST, $doNotValidateOtherFields ); -> fieldValues: {"xoo_el_reg_username":"nofyobopso","xoo_el_reg_email":"nofyobopso@gufum.com","xoo_el_reg_pass":"pouetpouet"}
- ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/xoo-form-fields-fw/admin/class-xoo-aff-fields.php
- 1213 : public function validate_submitted_field_values( $values = array(), $do_not_validate_ids = array() )
- 1222 : $fields = $this->get_fields_data()
- list that does not contains the contains the form fields
- values: {"xoo_el_reg_username":"tamludupsi","xoo_el_reg_email":"tamludupsi@gufum.com","xoo_el_reg_pass":"pouetpouet","_xoo_el_form":"register","cipf_user_role":"partenaire","xoo_el_redirect":"\/redirection_cipf","action":"xoo_el_form_action","display":"inline"}
- fields: {
"xoo_el_reg_fname":{"field_type":"xoo_el_reg_fname","input_type":"text","settings":{"required":"yes","label":"","cols":"onehalf","icon":"far fa-user","placeholder":"First Name","minlength":"","maxlength":"","class":"","active":"no","unique_id":"xoo_el_reg_fname"},"priority":"10"},
"xoo_el_reg_lname":{"field_type":"xoo_el_reg_lname","input_type":"text","settings":{"required":"yes","label":"","cols":"onehalf","icon":"far fa-user","placeholder":"Last Name","minlength":"","maxlength":"","class":"","active":"no","unique_id":"xoo_el_reg_lname"},"priority":"20"},
"xoo_el_reg_username":{"field_type":"xoo_el_reg_username","input_type":"text","settings":{"active":"yes","label":"Cr\u00e9er votre identifiant","cols":"one","icon":"fas fa-user-plus","placeholder":"","minlength":"3","maxlength":"20","class":"","unique_id":"xoo_el_reg_username","required":"yes"},"priority":"30"},
"xoo_el_reg_email":{"field_type":"xoo_el_reg_email","input_type":"email","settings":{"active":"yes","required":"yes","label":"Votre adresse mail","cols":"one","icon":"fas fa-at","placeholder":"","class":"","unique_id":"xoo_el_reg_email"},"priority":"40"},
"xoo_el_reg_pass":{"field_type":"xoo_el_reg_pass","input_type":"password","settings":{"active":"yes","label":"Cr\u00e9ez votre mot de passe","cols":"one","icon":"fas fa-key","placeholder":"8 caract\u00e8res minimum","minlength":"8","maxlength":"100","password_visibility":"yes","class":"","unique_id":"xoo_el_reg_pass","required":"yes"},"priority":"50"},
"xoo_el_reg_pass_again":{"field_type":"xoo_el_reg_pass_again","input_type":"password","settings":{"label":"","cols":"one","icon":"fas fa-key","placeholder":"Confirm Password","password_visibility":"yes","class":"","active":"no","unique_id":"xoo_el_reg_pass_again","required":"yes"},"priority":"60"},
"xoo_el_reg_terms":{"field_type":"xoo_el_reg_terms","input_type":"checkbox_single","settings":{"required":"yes","label":"","placeholder":"The Terms and Conditions","cols":"one","checkbox_single":{"yes":{"checked":"","label":"I accept the <a href=\"privacy-policy\" target=\"_blank\"> Terms of Service and Privacy Policy <\/a>","value":"yes","priority":"10"}},"class":"","active":"no","unique_id":"xoo_el_reg_terms"},"priority":"70"},
"xoo-el-username":{"field_type":"xoo-el-username","input_type":"text","settings":{"label":"Identifiant ou email","cols":"one","icon":"fas fa-user-plus","placeholder":"","class":"","unique_id":"xoo-el-username","required":"yes","active":"yes","elType":"login","custom_attributes":{"autocomplete":"username"}},"priority":"80"},
"xoo-el-password":{"field_type":"xoo-el-password","input_type":"password","settings":{"label":"Mot de passe","cols":"one","icon":"fas fa-key","placeholder":"","password_visibility":"yes","class":"","unique_id":"xoo-el-password","required":"yes","elType":"login","custom_attributes":{"autocomplete":"current-password"}},"priority":"90"},
"xoo-el-rp-pass":{"field_type":"xoo-el-rp-pass","input_type":"password","settings":{"label":"","cols":"one","icon":"fas fa-key","placeholder":"Nouveau mot de passe","minlength":"6","maxlength":"20","password_visibility":"yes","class":"","unique_id":"xoo-el-rp-pass","required":"yes","elType":"resetpw"},"priority":"100"},
"xoo-el-rp-pass-again":{"field_type":"xoo-el-rp-pass-again","input_type":"password","settings":{"required":"yes","unique_id":"xoo-el-rp-pass-again","elType":"resetpw","label":"","cols":"one","icon":"fas fa-key","placeholder":"Confirmer le mot de passe","password_visibility":"yes","class":""},"priority":"110"},
"user_login":{"field_type":"user_login","input_type":"text","settings":{"label":"","cols":"one","icon":"fas fa-user-plus","placeholder":"Identifiant\/e-mail","class":"","unique_id":"user_login","required":"yes","active":"yes","elType":"lostpw"},"priority":"120"},
"xoo-el-sing-user":{"field_type":"xoo-el-sing-user","input_type":"text","settings":{"unique_id":"xoo-el-sing-user","required":"yes","active":"yes","elType":"single","custom_attributes":{"autocomplete":"username"},"xoo_el_username":"yes","label":"","cols":"one","icon":"fas fa-user-plus","placeholder":"Identifiant\/e-mail","class":""},"priority":990}
}
---
do_action( 'xoo_el_created_customer', $customer_id, $new_customer_data);
../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
prof :
customer_id: 194
new_customer_data: {
"user_login":"dultiropso",
"user_pass":"pouetpouet",
"user_email":"dultiropso@gufum.com",
"role":"professeur__professeure"
}
user metas: {
"nickname":["dultiropso"],
"first_name":[""],
"last_name":[""],
"description":[""],
"rich_editing":["true"],
"syntax_highlighting":["true"],
"comment_shortcuts":["false"],
"admin_color":["fresh"],
"use_ssl":["0"],
"show_admin_bar_front":["true"],
"locale":[""],
"wp_503463_capabilities":["a:1:{s:23:\"professeur__professeure\";b:1;}"],
"wp_503463_user_level":["0"],
"dismissed_wp_pointers":[""]
}
partner :
customer_id: 195
new_customer_data: {
"user_login":"mistahirdu",
"user_pass":"pouetpouet",
"user_email":"mistahirdu@gufum.com",
"role":"professeur__professeure"
}
user metas: {
"nickname":["mistahirdu"],
"first_name":[""],
"last_name":[""],
"description":[""],
"rich_editing":["true"],
"syntax_highlighting":["true"],
"comment_shortcuts":["false"],
"admin_color":["fresh"],
"use_ssl":["0"],
"show_admin_bar_front":["true"],
"locale":[""],
"wp_503463_capabilities":["a:1:{s:23:\"professeur__professeure\";b:1;}"],
"wp_503463_user_level":["0"],
"dismissed_wp_pointers":[""]
}
---
do_action( 'xoo_el_register_add_fields', $args );
../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/templates/global/xoo-el-register-section.php