/*
Theme Name: Autobid Child
Theme URI: https://autobid.modeltheme.com/
Template: autobid
Author: ModelTheme
Author URI: http://modeltheme.com/
Description: Car Auctions Marketplace WooCommerce Theme
Version: 1.4.0
Text Domain: autobid
Tags: custom-header, custom-menu, featured-images, post-formats, sticky-post
*/
/* Theme customization starts here
------------------------------------------------------- */
function grant_seller_upload_capabilities() {
    $role = get_role( 'seller' );

    if ( $role ) {
        $role->add_cap( 'upload_files' );
        $role->add_cap( 'edit_posts' );       // needed for media library access
        $role->add_cap( 'delete_posts' );      // allows removing own media
        $role->add_cap( 'edit_published_posts' );
    }
}
add_action( 'init', 'grant_seller_upload_capabilities' );
function restrict_media_library_to_own( $query ) {
    if ( ! current_user_can( 'manage_options' ) ) {
        $query['author'] = get_current_user_id();
    }
    return $query;
}
add_filter( 'ajax_query_attachments_args', 'restrict_media_library_to_own' );