created plugin custer, and removed shortcodes change_id and user_infos from cipf plugin
This commit is contained in:
@@ -18,60 +18,12 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* version 4 :
|
||||
* modifying directly the current user : very hardcore, and need to store it
|
||||
*/
|
||||
function shortcode_choose_meta_id_CIPF ($options) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
// $role_fipf = PLGNTLS_class::ROLE_FIPF;
|
||||
// $role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||
//
|
||||
// $current_user = wp_get_current_user();
|
||||
//
|
||||
// $allowed_roles = array($role_admin, $role_fipf);
|
||||
// if (!array_intersect($allowed_roles, $current_user->roles))
|
||||
// return;
|
||||
|
||||
|
||||
$option = reset($options);
|
||||
if (!is_string($option)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($option === 'logged_in') {
|
||||
$id = get_current_user_id();
|
||||
error_log("logged_in id : " . $id);
|
||||
PLGNTLS_class::set_current_user_backup();
|
||||
wp_set_current_user($id);
|
||||
}
|
||||
else if ($option === 'post_creator') {
|
||||
$id = get_queried_object_id();
|
||||
error_log("post_creator id : " . $id);
|
||||
PLGNTLS_class::set_current_user_backup();
|
||||
wp_set_current_user($id);
|
||||
}
|
||||
else if ($option === 'off') {
|
||||
$id = PLGNTLS_class::reset_current_user_backup();
|
||||
error_log("reset id : " . $id);
|
||||
wp_set_current_user($id);
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
//add_action('set_current_user', 'force_set_user_CIPF');
|
||||
}
|
||||
add_shortcode('cipf_change_meta_id', 'shortcode_choose_meta_id_CIPF');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* version 3 :
|
||||
*
|
||||
* trying with a filter on wp_get_current_user()
|
||||
* used by form builder to retrieve the user before using get_metadat()
|
||||
* -> somehow the filter is never called
|
||||
* -> the filter is not called in most cases, if user is instance of WP_USER
|
||||
*/
|
||||
//function filter_user_id_CIPF($id) {
|
||||
// PLGNTLS_class::debug_infos();
|
||||
@@ -83,7 +35,8 @@ add_shortcode('cipf_change_meta_id', 'shortcode_choose_meta_id_CIPF');
|
||||
// error_log("-in add_filter_for_user_id_CIPF"); // this is output
|
||||
// add_filter('determine_current_user', 'filter_user_id_CIPF', 10, 1);
|
||||
//}
|
||||
//add_action('wp', 'add_filter_for_user_id_CIPF');
|
||||
//add_shortcode('cipf_change_meta_id', 'add_filter_for_user_id_CIPF');
|
||||
////add_action('wp', 'add_filter_for_user_id_CIPF');
|
||||
|
||||
|
||||
|
||||
@@ -114,11 +67,11 @@ add_shortcode('cipf_change_meta_id', 'shortcode_choose_meta_id_CIPF');
|
||||
//
|
||||
// $object_id = 117;
|
||||
//
|
||||
///*
|
||||
//* I just copied the code of wordpress :
|
||||
//* i'm not sure there is a better way
|
||||
//*
|
||||
//*/
|
||||
// /*
|
||||
// * I just copied the code of wordpress :
|
||||
// * i'm not sure there is a better way
|
||||
// *
|
||||
// */
|
||||
// $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' );
|
||||
//
|
||||
// if ( ! $meta_cache ) {
|
||||
@@ -141,9 +94,9 @@ add_shortcode('cipf_change_meta_id', 'shortcode_choose_meta_id_CIPF');
|
||||
// return array_map( 'maybe_unserialize', $meta_cache[ $meta_key ] );
|
||||
// }
|
||||
// }
|
||||
///*
|
||||
//* FIN copy
|
||||
//*/
|
||||
// /*
|
||||
// * FIN copy
|
||||
// */
|
||||
//}
|
||||
//function add_filter_for_user_id_CIPF($wp) {
|
||||
// PLGNTLS_class::debug_infos();
|
||||
|
||||
Reference in New Issue
Block a user