WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a weird issue. My post thumbnails aren't working with a custom role. Images can be uploaded, and when viewing the media uploader they show as attached to the relevant post. However, when calling the thumbnail is returns nothing.

I am running some PHP to filter what posts the author can see, could this be the issue?

Here's the role;

    'dealer',//name of role
    'Dealer',//display name of role
    array(//array of capabilities 
        'read' => TRUE,
        'edit_posts' => TRUE,
        'publish_posts' => TRUE,
        'upload_files' => TRUE,
        'edit_published_posts' => TRUE,
        'delete_posts' => TRUE //to allow media to be deleted 

This is one of the filters, picked up from this forum I believe;

//filter posts for dealer user
function ik_eyes_only( $wp_query ) 
    if(strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false || strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) 
    { //user level 5 converts to Editor 
        if ( !current_user_can( 'level_5' ) ) 
            { //restrict the query to current user 
                global $current_user; 
                $wp_query->set( 'author', $current_user->ID ); 
add_filter('parse_query', 'ik_eyes_only' );

..and this should be the other one that might be the issue..

function ml_restrict_media_library( $wp_query_obj ) 
    global $current_user, $pagenow;
    if( !is_a( $current_user, 'WP_User') )
    if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )
    if( !current_user_can('manage_media_library') )
    $wp_query_obj->set('author', $current_user->ID );

Any ideas? This one is driving me nuts!!!

share|improve this question
What do you mean by "calling the thumbnail"? Where is that code? – s_ha_dum Sep 13 '13 at 18:10
has_post_thumbnail() The rest of the code works when the author is admin level, but this role does not work as it should. – Dan Sep 13 '13 at 18:17
has_post_thumbnail() doesn't echo anything. What do you mean by "Images can be uploaded"? Do you see the "Featured Image" meta box? – s_ha_dum Sep 13 '13 at 19:10
Yeah, I'm not new to this, only the permissions of a custom user role. I regularly work with featured images and the type of query I'm using. – Dan Sep 13 '13 at 21:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.