Support » Plugins » Hacks » WP 3.5 Media Library items limit

  • Mesasix

    (@jervenmatthew)


    Hi everyone.

    My understanding of the new WP 3.5 Modal Uploader Media Library Tab (wp.media.frames.file_frame) contents is that it queries wordpress via Ajax and admin-ajax.php and executes the function wp_ajax_query_attachments. I want to limit media showing on the Media Library tab modal to its specific author, meaning images in that said tab should only be visible to the one who uploads it.

    I tried several suggestions including pre_get_posts, where filter, etc but did’nt seem to do it.

    My solution is to add an action with the tag “wp_ajax_query_attachments” and put the priority to 999 but it doesnt override the core function. I tried removing the action via hooks (admin_init and init) and add my own function via add_action but to no avail.

    Hope anyone can help me out.

    Thanks,
    Matt

    PS. for the meantime, I edited core file ajax-actions.php and added $query[‘author’] = get_current_user_id(); to the query. I know this is bad practice but it leaves me no choice šŸ™

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The correct filter to alter the query used by wp_ajax_query_attachments() is ‘ajax_query_attachments_args’. Your filter callback is passed the function’s current WP_Query arguments. Merge array('author' => get_current_user_id(),); with that array and return the whole thing.

Viewing 1 replies (of 1 total)
  • The topic ‘WP 3.5 Media Library items limit’ is closed to new replies.