- wip create role at registration
- upgraded shortcode user_infos to output acf format
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
<?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 add_form_calculation_patch_CIPF() {
|
||||
error_log('inside wp_enqueue');
|
||||
|
||||
$handle = 'form_calculation_patch';
|
||||
$url = PLGNTLS_class::root_url() . 'js/form_builder_patch/form_calculation.js';
|
||||
$dependencies = array('de_fb_calc');
|
||||
|
||||
@@ -13,9 +13,15 @@ if (!defined('ABSPATH')) {
|
||||
* at registration, add role 'partenaire' when page url has path 'creation-du-compte-partenaire'
|
||||
*
|
||||
*/
|
||||
function add_partenaires_PLGNTLS($customer_data){
|
||||
function add_partenaires_CIPF($customer_data){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$role_partner = PLGNTLS_class::ROLE_PARTNER;
|
||||
error_log("----");
|
||||
error_log("in add_partenaires");
|
||||
error_log("_POST");
|
||||
error_log(json_encode($_POST));
|
||||
error_log("_SERVER");
|
||||
error_log(json_encode($_SERVER));
|
||||
|
||||
$current_url = $_SERVER['HTTP_REFERER']; // not reliable to use referer, TODO: find another solution
|
||||
$path_brut = parse_url($current_url, PHP_URL_PATH);
|
||||
@@ -24,7 +30,69 @@ function add_partenaires_PLGNTLS($customer_data){
|
||||
$customer_data['role'] = $role_partner;
|
||||
return $customer_data;
|
||||
}
|
||||
add_filter( 'xoo_el_register_new_customer_data', 'add_partenaires_PLGNTLS', 10, 1 );
|
||||
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
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -61,7 +61,7 @@ function output_list_front_CIPF($array) {
|
||||
}
|
||||
|
||||
|
||||
function format_user_info_CIPF($output, $query, &$current_user, $user_id) {
|
||||
function format_user_info_CIPF($query, &$current_user, $user_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$output_date_format = PLGNTLS_class::USER_INFO_DATE_FORMAT;
|
||||
|
||||
@@ -88,6 +88,18 @@ function format_user_info_CIPF($output, $query, &$current_user, $user_id) {
|
||||
if ($acf_object !== false)
|
||||
$is_acf = true;
|
||||
|
||||
|
||||
/*
|
||||
* if is acf, use the acf return format
|
||||
* otherwise, use the default wordpress value
|
||||
*
|
||||
*/
|
||||
if ($is_acf)
|
||||
$output = get_field($query, $acf_id);
|
||||
else
|
||||
$output = $current_user->$query;
|
||||
|
||||
|
||||
/*
|
||||
* check if is date
|
||||
*
|
||||
@@ -98,6 +110,7 @@ function format_user_info_CIPF($output, $query, &$current_user, $user_id) {
|
||||
$is_date = true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* if is date, transform format
|
||||
*
|
||||
@@ -109,6 +122,7 @@ function format_user_info_CIPF($output, $query, &$current_user, $user_id) {
|
||||
$output = $date->format($output_date_format);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return the result
|
||||
*
|
||||
@@ -217,8 +231,8 @@ function current_user_infos_CIPF($atts) {
|
||||
$query = $atts;
|
||||
else
|
||||
return '';
|
||||
$output = $current_user->$query;
|
||||
return format_user_info_CIPF($output, $query, $current_user, $user_id);
|
||||
// $output = $current_user->$query;
|
||||
return format_user_info_CIPF($query, $current_user, $user_id);
|
||||
}
|
||||
add_shortcode('cipf_user_info', 'current_user_infos_CIPF');
|
||||
|
||||
|
||||
2
private
2
private
Submodule private updated: a37c901a74...56b1f351d4
Reference in New Issue
Block a user