From d65af4cd43b8ad1662e0d6460420c17db2af39a7 Mon Sep 17 00:00:00 2001 From: asus Date: Thu, 7 Mar 2024 17:05:55 +0100 Subject: [PATCH] - wip filter page prof - upgraded user info shortcode to default behavior on author page --- .../php/author_restriction.php | 8 ++++ plugins/fipfcard_plugin/php/can_user_pay.php | 14 ------ plugins/fipfcard_plugin/php/filter_mail.php | 8 ++++ .../fipfcard_plugin/php/prof_check_page.php | 32 ++++++++++--- .../fipfcard_plugin/php/reset_acf_fields.php | 8 ++++ plugins/fipfcard_plugin/php/user_infos.php | 46 ++++++++++--------- 6 files changed, 73 insertions(+), 43 deletions(-) delete mode 100644 plugins/fipfcard_plugin/php/can_user_pay.php diff --git a/plugins/fipfcard_plugin/php/author_restriction.php b/plugins/fipfcard_plugin/php/author_restriction.php index dc91c51..aec9db2 100644 --- a/plugins/fipfcard_plugin/php/author_restriction.php +++ b/plugins/fipfcard_plugin/php/author_restriction.php @@ -1,5 +1,13 @@ diff --git a/plugins/fipfcard_plugin/php/filter_mail.php b/plugins/fipfcard_plugin/php/filter_mail.php index 1b331b3..18e4f85 100644 --- a/plugins/fipfcard_plugin/php/filter_mail.php +++ b/plugins/fipfcard_plugin/php/filter_mail.php @@ -1,5 +1,13 @@ - diff --git a/plugins/fipfcard_plugin/php/reset_acf_fields.php b/plugins/fipfcard_plugin/php/reset_acf_fields.php index c53d3e0..bbae57d 100644 --- a/plugins/fipfcard_plugin/php/reset_acf_fields.php +++ b/plugins/fipfcard_plugin/php/reset_acf_fields.php @@ -1,5 +1,13 @@ list of all availables infos -* - [cipf_user_info user_email] -> display the email -* - [cipf_user_info user_email user_login] -> display the email -* - [cipf_user_info user_email author] -> display the email of the author of the page/post instead of the connected user +* - [cipf_user_info] -> list of all availables infos +* - [cipf_user_info user_email] -> display the email +* - [cipf_user_info user_email user_login] -> display the email +* - [cipf_user_info user_email author='logged_in'] -> display the email of the connected user +* - [cipf_user_info user_email author='post_creator'] -> display the email of the creator of the page/post * */ function current_user_infos_CIPF($atts) { if (!is_user_logged_in()) return ; - error_log("--atts"); - error_log(json_encode($atts)); - $current_user = wp_get_current_user(); - $user_id = get_current_user_id(); + /* + * choose the default id target : logged in user, or post creator ? + * + $author_is = 'logged_in'; // logged in user + */ + $author_is = 'post_creator'; // creator of post (also for author pages) + /* * has parameter 'author' ? * if yes, removes it from $atts * */ - $has_author = false; if (is_array($atts)) { - $needle_key = array_search('author', $atts); - if ($needle_key !== false) { - unset($atts[$needle_key]); - $has_author = true; - } - } - else { - if ($atts === 'author') { - $atts = ''; - $has_author = true; + $author = $atts['author']; + if (isset($author)) { + $author_is = $author; + unset($atts['author']); } } - error_log(json_encode($atts)); + /* * should output all or a specific parameter ? * @@ -166,11 +163,16 @@ function current_user_infos_CIPF($atts) { else if (count($atts) === 0) $output_all = true; + /* * get author id outside loop and outside singular page : https://wordpress.stackexchange.com/q/65548 * */ - if ($has_author) { + if ($author_is === 'logged_in') { + $current_user = wp_get_current_user(); + $user_id = get_current_user_id(); + } + else { if (is_author()) { $user_id = get_queried_object_id(); }