• Resolved nasirmajor

    (@nasirmajor)


    when user is on the add posts page(in adminpanel) and click on add video/audio icon and popup comes up then i only want that user to see his own added media files but not others.

    How can i achive this ? any help please..

    I know that these lines(1052 onward) in wordpress/wp-admin/includes/media.php are bringing that data. but how can i customise the query??

    if ( is_array($GLOBALS[‘wp_the_query’]->posts) )
    foreach ( $GLOBALS[‘wp_the_query’]->posts as $attachment )
    $attachments[$attachment->ID] = $attachment;

Viewing 1 replies (of 1 total)
  • Thread Starter nasirmajor

    (@nasirmajor)

    its done! by declaring global variable wpdb and using custom query.
    and replacing following lines
    ———
    if ( is_array($GLOBALS[‘wp_the_query’]->posts) )
    foreach ( $GLOBALS[‘wp_the_query’]->posts as $attachment )
    $attachments[$attachment->ID] = $attachment;

    ———
    with following lines
    ———
    global $wpdb;

    $countResult = $wpdb->get_results( “SELECT * FROM wp_posts where post_author=3 and post_type=’attachment'” );

    if (is_array($countResult))
    foreach ( $countResult as $attachment )
    $attachments[$attachment->ID] = $attachment;
    ===========================

    of course you can replace 3 with logged in post_author id.

Viewing 1 replies (of 1 total)
  • The topic ‘just user own attachments should be viewable in adminpanel’ is closed to new replies.