WordPress – View only own media

WordPress – View only own media

function my_files_only( $wp_query )
{

        if ( ! $_POST["action"] == "attachment" )
        {
                return;
        }

        if ( current_user_can( 'administrator' ) )
        {
                return;
        }

        global $current_user;
        $wp_query->set( 'author', $current_user->id );

}

add_filter('parse_query', 'my_files_only' );
Comments are closed.