get_posts() doesn’t consider user permissions

Use is_user_logged_in you code may like $posts_array = get_posts( array( ‘post_type’ => ‘download’, ‘post_status’ => ‘publish’ ) ); //$posts_array = apply_filters( ‘downloads_shortcode’, $posts_array ); foreach($posts_array as $post) { setup_postdata($post); if ( is_user_logged_in() ){ $title = “<a href=”https://wordpress.stackexchange.com/questions/100335/. get_permalink( $post->ID ) .”>” . $post->post_title . “</a>”; echo $title; } else{ // do something } } Note:If … Read more

Custom Post Type Capabilities

Ok – lets try this again 🙂 I added the map_meta_cap parameter which is needed to have delete_others_posts work. Now I was able to get authors to edit and view all posts but only delete their own. $labels = array( ‘name’ => __( ‘Book’, ‘textdomain’ ), ‘singular_name’ => __( ‘Book’, ‘textdomain’ ), ‘menu_name’ => __( … Read more

Restricted user capabilities cannot add image

You haven’t missed any capabilities. User should be able to insert images into the editor with these capabilities. The only problem I can think of is that, you are trying to modify the capabilities of a role which won’t work. See this section If you are defining a custom role, and adding capabilities to the … Read more

current_user_can() return FALSE but debugging says TRUE

The register_post_type() function takes a post type name as argument for map_meta_cap, where the default is post. Take a look at the internals of get_post_type_capabilities() for extended insights. That should help you to understand how it’s meant to be: function get_post_type_capabilities( $args ) { if ( ! is_array( $args->capability_type ) ) $args->capability_type = array( $args->capability_type, … Read more

Adding an additional role to an Administrator

use the profile_update hook and in the hooked function, run this check to make sure that it’s adding the previous data to the users profile on update too. if ( $update ){ do_action(‘profile_update’, $user_id, $old_user_data); }else{ do_action(‘user_register’, $user_id); } return $user_id; This answer can help you understand it more: WordPress edit_user_profile_update update secondary role