Plugin Author
finnj
(@finnj)
Hey finnj! Thanks for your prompt answer.
I am currently using the simple visual editor. What is the name of the template? Old, simple or standard?
One more question.
Is there a way to restrict access to the whole media library when user uploading a feature image? I mean upload a featured image directly from pc only?
Thanks again!
Ok, i managed to restrict access to the whole media library when user uses the “add media” button (he can see only his files)
here is the code, inserted in functions.php
add_action('pre_get_posts','ml_restrict_media_library');
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;
}
I am still trying to figure out how this can be done with “select featured image”.
Any help?
Also, how can i replace text “select featured image” with a button?
Thanks!
ok, this is an update!
DISREGARD THE ABOVE CODE!
works fine, but admin cannot see the whole library either!!!
so this is the right code
function my_files_only( $wp_query ) {
if ($wp_query->query_vars['post_type']=="attachment"){
if ( !current_user_can( 'level_5' ) ) {
global $current_user;
$wp_query->set( 'author', $current_user->id );
}
}
}
add_filter('parse_query', 'my_files_only' );
still looking for the featured image thing…
any help much appreciated!
Plugin Author
finnj
(@finnj)
As for restricting media access, try and look here: http://wpfrontier.com/restrict-backend-access-and-access-to-others-media/
The capabability used to check access in this code is “edit_others_posts” – Administeators and editors has this.