Files
2024_WEBSITE_fipf/plugins/cipf_plugin/php/partners_register.php

215 lines
6.2 KiB
PHP

<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
function check_fields_CIPF($fields) {
error_log("--- in check_fields_CIPF");
error_log("fields");
error_log(json_encode($fields));
return $fields;
}
add_filter('xoo_el_register_fields', 'check_fields_CIPF');
/*
{
"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"}}
*/
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');
/*
* at registration, add role 'partenaire' when page url has path 'creation-du-compte-partenaire'
*
*/
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);
/*
in add_partenaires
_POST
{
"xoo_el_reg_username":"tistilarde",
"xoo_el_reg_email":"tistilarde@gufum.com",
"xoo_el_reg_pass":"pouetpouet",
"_xoo_el_form":"register",
"xoo_el_redirect":"\/creation-du-compte-partenaire\/",
"action":"xoo_el_form_action",
"display":"popup"
}
_SERVER
{
"SERVER_SOFTWARE":"nginx\/1.20.2",
"REQUEST_URI":"\/wp-admin\/admin-ajax.php",
"USER":"www-data",
"HOME":"\/home\/www-data",
"HTTP_SEC_FETCH_SITE":"same-origin",
"HTTP_SEC_FETCH_MODE":"cors",
"HTTP_SEC_FETCH_DEST":"empty",
"HTTP_COOKIE":"wordpress_test_cookie=WP%20Cookie%20check; wp-postpass_351da2be51e3820c1ef099eec9d2e669=%24P%24BjEiJgHo.cgrpONdnfmxwpIYzraFCP.; mjx.menu=renderer%3ANativeMML%26%3Bsemantics%3Atrue%26%3Bcontext%3ABrowser%26%3Bzoom%3ANone",
"HTTP_REFERER":"https:\/\/local-cipf-plugin.com\/creation-du-compte-partenaire\/",
"HTTP_CONNECTION":"keep-alive",
"HTTP_SEC_GPC":"1",
"HTTP_DNT":"1",
"HTTP_ORIGIN":"https:\/\/local-cipf-plugin.com",
"HTTP_CONTENT_LENGTH":"211",
"HTTP_X_REQUESTED_WITH":"XMLHttpRequest",
"HTTP_CONTENT_TYPE":"application\/x-www-form-urlencoded; charset=UTF-8",
"HTTP_ACCEPT_ENCODING":"gzip, deflate, br",
"HTTP_ACCEPT_LANGUAGE":"en-US,en;q=0.5",
"HTTP_ACCEPT":"*\/*",
"HTTP_USER_AGENT":"Mozilla\/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko\/20100101 Firefox\/123.0",
"HTTP_HOST":"local-cipf-plugin.com",
"REDIRECT_STATUS":"200",
"SERVER_NAME":"local-cipf-plugin.com",
"SERVER_PORT":"443",
"SERVER_ADDR":"172.20.0.4",
"REMOTE_PORT":"58976",
"REMOTE_ADDR":"172.20.0.1",
"GATEWAY_INTERFACE":"CGI\/1.1",
"HTTPS":"on",
"REQUEST_SCHEME":"https",
"SERVER_PROTOCOL":"HTTP\/1.1",
"DOCUMENT_ROOT":"\/var\/www\/html",
"DOCUMENT_URI":"\/wp-admin\/admin-ajax.php",
"SCRIPT_NAME":"\/wp-admin\/admin-ajax.php",
"CONTENT_LENGTH":"211",
"CONTENT_TYPE":"application\/x-www-form-urlencoded; charset=UTF-8",
"REQUEST_METHOD":"POST",
"QUERY_STRING":"",
"SCRIPT_FILENAME":"\/var\/www\/html\/wp-admin\/admin-ajax.php",
"FCGI_ROLE":"RESPONDER",
"PHP_SELF":"\/wp-admin\/admin-ajax.php",
"REQUEST_TIME_FLOAT":1710328883.257681,
"REQUEST_TIME":1710328883
}
*/
?>