Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('wp_head', 'change_fp_ids');
- function change_fp_ids(){
- add_filter('fpc_featured_pages_ids', 'my_fp_ids', 20);
- function my_fp_ids( $fp_ids ){
- $role_page = array(
- // Role => Page/Post name
- 'administrator' => 'Blog',
- 'editor' => 'A',
- );
- // do nothing if in admin backend or in the customize
- if ( is_admin() || TC___::$instance -> is_customizing )
- return $fp_ids;
- $current_user_role = get_current_user_role();
- if ( ! array_key_exists( $current_user_role, $role_page ) )
- return $fp_ids;
- $i = 0;
- foreach ( $fp_ids as $fp_id ){
- $fp_page_id = esc_attr( tc__f( '__get_fpc_option' , 'tc_featured_page_'.$fp_id) );
- /* now you have the id of the page/post and you can make your checks on it */
- /* if this check fails keep the fp_id otherwise unset it */
- if ( $role_page[ $current_user_role ] == get_the_title($fp_page_id) ){
- array_splice( $fp_ids, $i, 1);
- }
- $i++;
- }
- return $fp_ids;
- }
- }
- if (! function_exists('get_current_user_role') ){
- function get_current_user_role() {
- if ( is_user_logged_in() ) {
- global $current_user;
- $user_role = $current_user->roles[0];
- return $user_role;
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment