134 lines
3.6 KiB
PHP
134 lines
3.6 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_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
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
?>
|