v 0.3.3 partner registration detected with slug using options and without referer
This commit is contained in:
@@ -4,7 +4,7 @@ Plugin Name: cipf_plugin
|
|||||||
Plugin URI:
|
Plugin URI:
|
||||||
Description:
|
Description:
|
||||||
Author: hugogogo
|
Author: hugogogo
|
||||||
Version: 0.3.2
|
Version: 0.3.3
|
||||||
Author URI:
|
Author URI:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -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'
|
* 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){
|
function add_partenaires_CIPF($customer_data){
|
||||||
PLGNTLS_class::debug_infos();
|
PLGNTLS_class::debug_infos();
|
||||||
$role_partner = PLGNTLS_class::ROLE_PARTNER;
|
$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, '/');
|
$partner_slug_option = get_option($option_partner_slug['_name']);
|
||||||
if ($path === 'creation-du-compte-partenaire')
|
$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;
|
$customer_data['role'] = $role_partner;
|
||||||
|
}
|
||||||
return $customer_data;
|
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
|
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!');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -82,6 +82,7 @@ class PLGNTLS_class {
|
|||||||
const SLUG_PAYPAL_REDIRECTION_SUCCESS = self::SLUG_PAGE_REDIRECTION;
|
const SLUG_PAYPAL_REDIRECTION_SUCCESS = self::SLUG_PAGE_REDIRECTION;
|
||||||
const SLUG_PAYPAL_REDIRECTION_FAILURE = self::SLUG_PAGE_REDIRECTION;
|
const SLUG_PAYPAL_REDIRECTION_FAILURE = self::SLUG_PAGE_REDIRECTION;
|
||||||
const SLUG_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php
|
const SLUG_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php
|
||||||
|
const SLUG_PARTNER_REGISTRATION = 'creation-du-compte-partenaire';
|
||||||
// URL
|
// URL
|
||||||
const URL_BASE_REST_ROUTE = 'cipf_plugin/api/v1'; // for routes, in php/paypal/routes.php && php/admin_modif_prof.php
|
const URL_BASE_REST_ROUTE = 'cipf_plugin/api/v1'; // for routes, in php/paypal/routes.php && php/admin_modif_prof.php
|
||||||
// QUERY
|
// QUERY
|
||||||
@@ -101,6 +102,9 @@ class PLGNTLS_class {
|
|||||||
|
|
||||||
// SHORTCODES
|
// SHORTCODES
|
||||||
|
|
||||||
|
// OPTIONS
|
||||||
|
const OPTION_PARTNER_SLUG = ['_name'=>'cipf_partner_slug', 'true'=>'true', 'false'=>'false'];
|
||||||
|
|
||||||
// OTHER
|
// OTHER
|
||||||
const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible
|
const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible
|
||||||
const CARD_VALIDITY_TIME = '1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days')
|
const CARD_VALIDITY_TIME = '1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days')
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Plugin Name: custer_plugin
|
|||||||
Plugin URI:
|
Plugin URI:
|
||||||
Description: customize user : output infos on page, on email, and change current user id momentarly
|
Description: customize user : output infos on page, on email, and change current user id momentarly
|
||||||
Author: hugogogo
|
Author: hugogogo
|
||||||
Version: 0.1.3
|
Version: 0.1.4
|
||||||
Author URI:
|
Author URI:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -27,7 +27,6 @@ include_once(plugin_dir_path(__FILE__) . '/filter_mail.php');
|
|||||||
include_once(plugin_dir_path(__FILE__) . '/admin_menu.php');
|
include_once(plugin_dir_path(__FILE__) . '/admin_menu.php');
|
||||||
include_once(plugin_dir_path(__FILE__) . '/admin_menu_toggle.php');
|
include_once(plugin_dir_path(__FILE__) . '/admin_menu_toggle.php');
|
||||||
|
|
||||||
//add_shortcode('custer_change_id', 'CUSTER\shortcode_change_id');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -87,15 +87,10 @@ function filter_email_wp($args) {
|
|||||||
// pattern : anything surrounded by '$$', ex : $$value$$
|
// pattern : anything surrounded by '$$', ex : $$value$$
|
||||||
$pattern = '/\$\$(.*?)\$\$/';
|
$pattern = '/\$\$(.*?)\$\$/';
|
||||||
|
|
||||||
error_log("inside wp_mail hook, in filter_email_wp");
|
|
||||||
|
|
||||||
$old_body = $args['message'];
|
$old_body = $args['message'];
|
||||||
$new_body = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_body);
|
$new_body = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_body);
|
||||||
$args['message'] = $new_body;
|
$args['message'] = $new_body;
|
||||||
|
|
||||||
error_log("args['message']");
|
|
||||||
error_log(json_encode($args['message']));
|
|
||||||
|
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
add_filter('wp_mail', __NAMESPACE__.'\filter_email_wp', 10, 1);
|
add_filter('wp_mail', __NAMESPACE__.'\filter_email_wp', 10, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user