wip partner register role : found how to add hidden fields

This commit is contained in:
asus
2024-03-21 19:26:32 +01:00
parent 66fbbfd586
commit ab9afab160
3 changed files with 211 additions and 60 deletions

View File

@@ -10,21 +10,94 @@ if (!defined('ABSPATH')) {
function check_fields_CIPF($fields) {
//function check_fields_CIPF($fields) {
// error_log("--- in check_fields_CIPF");
// error_log("fields");
// error_log(json_encode($fields));
//
// $tmp_fields = array_slice($fields, 0);
// error_log("tmp_fields");
// error_log(json_encode($tmp_fields));
// $tmp_fields[] = array(
// "field_type"=>"test",
// "input_type"=>"text",
// "settings"=>array
// (
// "required"=>"yes",
// "label"=>"",
// "cols"=>"onehalf",
// "icon"=>"",
// "placeholder"=>"test",
// "minlength"=>"",
// "maxlength"=>"",
// "class"=>"",
// "active"=>"no",
// "unique_id"=>"test"
// ),
// "priority"=>"10"
// );
// error_log("--tmp_fields");
// error_log(json_encode($tmp_fields));
// error_log("--fields");
// error_log(json_encode($fields));
//
//
// return $fields;
//}
//add_filter('xoo_el_register_fields', 'check_fields_CIPF');
return $fields;
function test_add_fields_register_CIPF($args) {
error_log("args : " . json_encode($args));
echo '<input type="hidden" name="_test_hugo" value="test_hugo">';
}
add_filter('xoo_el_register_fields', 'check_fields_CIPF');
add_action( 'xoo_el_register_add_fields', 'test_add_fields_register_CIPF' );
/*
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
args :
{
"xoo_el_reg_fname":{
"display":"inline",
"form_active":"register",
"return":true,
"navstyle":"disable",
"forms":
{
"single":{"enable":"no"},
"login":{"enable":"yes"},
"register":{"enable":"yes"},
"lostpw":{"enable":"yes"}
},
"tabs":["register"]
}
---
function check_data_CIPF($data) {
error_log("--- in check_data_CIPF");
error_log("data");
error_log(json_encode($data));
return $data;
}
add_filter('xoo_aff_easy-login-woocommerce_data', 'check_data_CIPF');
../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/xoo-form-fields-fw/admin/class-xoo-aff-fields.php
../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-fields.php
{
"xoo_el_reg_fname":
{
"field_type":"xoo_el_reg_fname",
"input_type":"text",
"settings":{
"settings":
{
"required":"yes",
"label":"",
"cols":"onehalf",
@@ -38,10 +111,12 @@ add_filter('xoo_el_register_fields', 'check_fields_CIPF');
},
"priority":"10"
},
"xoo_el_reg_lname":{
"xoo_el_reg_lname":
{
"field_type":"xoo_el_reg_lname",
"input_type":"text",
"settings":{
"settings":
{
"required":"yes",
"label":"",
"cols":"onehalf",
@@ -55,10 +130,12 @@ add_filter('xoo_el_register_fields', 'check_fields_CIPF');
},
"priority":"20"
},
"xoo_el_reg_username":{
"xoo_el_reg_username":
{
"field_type":"xoo_el_reg_username",
"input_type":"text",
"settings":{
"settings":
{
"active":"yes",
"label":"Cr\u00e9er votre identifiant",
"cols":"one",
@@ -72,10 +149,12 @@ add_filter('xoo_el_register_fields', 'check_fields_CIPF');
},
"priority":"30"
},
"xoo_el_reg_email":{
"xoo_el_reg_email":
{
"field_type":"xoo_el_reg_email",
"input_type":"email",
"settings":{
"settings":
{
"active":"yes",
"required":"yes",
"label":"Votre adresse mail",
@@ -86,36 +165,108 @@ add_filter('xoo_el_register_fields', 'check_fields_CIPF');
"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_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"
}
}
*/
function check_if_partner_registration_CIPF() {
PLGNTLS_class::debug_infos();
$slug_partner_registration = PLGNTLS_class::SLUG_PARTNER_REGISTRATION;
$option_partner_slug = PLGNTLS_class::OPTION_PARTNER_SLUG;
/*
* if does not exist, create the option
*/
if (false === get_option($option_partner_slug['_name'])) {
add_option($option_partner_slug['_name'], array());
}
global $wp;
$current_slug = $wp->request;
if ($current_slug !== $slug_partner_registration) {
update_option($option_partner_slug['_name'], $option_partner_slug['false']);
return;
}
//PLGNTLS_class::set_partner_registration();
update_option($option_partner_slug['_name'], $option_partner_slug['true']);
}
add_action('template_redirect', 'check_if_partner_registration_CIPF');
/*
* BAD OLD METHOD
* when arriving on the partner registration page
* -> add an option (really not a good idea)
* option is bad, it will be global to all users
*
*/
//function check_if_partner_registration_CIPF() {
// PLGNTLS_class::debug_infos();
// $slug_partner_registration = PLGNTLS_class::SLUG_PARTNER_REGISTRATION;
// $option_partner_slug = PLGNTLS_class::OPTION_PARTNER_SLUG;
//
//
// /*
// * if does not exist, create the option
// */
// if (false === get_option($option_partner_slug['_name'])) {
// add_option($option_partner_slug['_name'], array());
// }
//
// global $wp;
// $current_slug = $wp->request;
// if ($current_slug !== $slug_partner_registration) {
// update_option($option_partner_slug['_name'], $option_partner_slug['false']);
// return;
// }
//
// //PLGNTLS_class::set_partner_registration();
// update_option($option_partner_slug['_name'], $option_partner_slug['true']);
//}
//add_action('template_redirect', 'check_if_partner_registration_CIPF');
@@ -123,27 +274,31 @@ add_action('template_redirect', 'check_if_partner_registration_CIPF');
/*
* at registration, add role 'partenaire' when page url has path 'creation-du-compte-partenaire'
* BAD OLD METHOD
* at registration, add role 'partenaire'
* if option (created with hook 'template redirect') has the partner registration slug
* -> give partner role
* option is bad, it will be global to all users
*
*/
function add_partenaires_CIPF($customer_data){
PLGNTLS_class::debug_infos();
$role_partner = PLGNTLS_class::ROLE_PARTNER;
$option_partner_slug = PLGNTLS_class::OPTION_PARTNER_SLUG;
/*
*/
$partner_slug_option = get_option($option_partner_slug['_name']);
$is_partner_slug = false;
if ($partner_slug_option === $option_partner_slug['true']) {
$is_partner_slug = true;
}
if ($is_partner_slug) {
$customer_data['role'] = $role_partner;
}
return $customer_data;
}
add_filter('xoo_el_register_new_customer_data', 'add_partenaires_CIPF', 10, 1);
//function add_partenaires_CIPF($customer_data){
// PLGNTLS_class::debug_infos();
// $role_partner = PLGNTLS_class::ROLE_PARTNER;
// $option_partner_slug = PLGNTLS_class::OPTION_PARTNER_SLUG;
//
// /*
// */
// $partner_slug_option = get_option($option_partner_slug['_name']);
// $is_partner_slug = false;
// if ($partner_slug_option === $option_partner_slug['true']) {
// $is_partner_slug = true;
// }
// if ($is_partner_slug) {
// $customer_data['role'] = $role_partner;
// }
// return $customer_data;
//}
//add_filter('xoo_el_register_new_customer_data', 'add_partenaires_CIPF', 10, 1);