I am trying to limit the files that are shown in the wordpress media library popup (from wp_editor).
Currently every single file that I have ever uploaded to my site is shown in the library but I would like to limit what users see to just files uploaded in the last 24 hours.
It is possible to limit the media library by author using the following code; however I'm not even sure where to start to limit the media library popup to files uploaded in the last 24 hours.
add_action('pre_get_posts','users_own_attachments');
function users_own_attachments( $wp_query_obj ) {
global $current_user, $pagenow;
if( !is_a( $current_user, 'WP_User') )
return;
if( !in_array( $pagenow, array( 'upload.php', 'admin-ajax.php' ) )
return;
if( !current_user_can('delete_pages') )
$wp_query_obj->set('author', $current_user->ID );
return;
}