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

72 lines
1.7 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!');
}
/*
* 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();
$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', '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_role_partners_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])) {
return $customer_data;
}
if ($_POST[$input_hidden_role] === $role_partner) {
$customer_data['role'] = $role_partner;
}
return $customer_data;
}
add_filter('xoo_el_register_new_customer_data', 'add_role_partners_CIPF', 10, 1);
?>