v 0.3.3 partner registration detected with slug using options and without referer
This commit is contained in:
@@ -9,6 +9,38 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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'
|
||||
*
|
||||
@@ -16,15 +48,24 @@ if (!defined('ABSPATH')) {
|
||||
function add_partenaires_CIPF($customer_data){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$role_partner = PLGNTLS_class::ROLE_PARTNER;
|
||||
$option_partner_slug = PLGNTLS_class::OPTION_PARTNER_SLUG;
|
||||
|
||||
$current_url = $_SERVER['HTTP_REFERER']; // not reliable to use referer, TODO: find another solution
|
||||
$path_brut = parse_url($current_url, PHP_URL_PATH);
|
||||
$path = trim($path_brut, '/');
|
||||
if ($path === 'creation-du-compte-partenaire')
|
||||
/*
|
||||
*/
|
||||
$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 );
|
||||
add_filter('xoo_el_register_new_customer_data', 'add_partenaires_CIPF', 10, 1);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
in add_partenaires
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user