Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Zayed!

    That’s a wonderfull plugin. I sent you a message (zayedbaloch(at)gmail.com) regarding the code.

    Trying to figure out whre should i place it. Would appreciate your help.

    Thanks in advance.

    Thread Starter manolo13

    (@manolo13)

    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!

    Thread Starter manolo13

    (@manolo13)

    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!

    Thread Starter manolo13

    (@manolo13)

    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!

Viewing 4 replies - 1 through 4 (of 4 total)