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;
add_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') )
return;
if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )
return;
if( !current_user_can('manage_media_library') )
$wp_query_obj->set('author', $current_user->ID );
return;
}
add_action('pre_get_posts','ml_restrict_media_library');
Any ideas? This one is driving me nuts!!!