wp query with dynamic taxonomies and terms?

Here is one idea for a dynamic multiple taxonomy query:

// construct the tax-query: 
$tax_query = array( 'relation' => 'AND' );

// check if movie_genre taxonomy is to be included
if( $bMovieGenre ){
    $tax_query[] = array(
        'taxonomy' => 'movie_genre',
        'field'    => 'slug',
        'terms'    => array( 'action', 'comedy' )
    );
 }

// check if actor taxonomy is to be included
if( $bActor ){
    $tax_query[] = array(
        'taxonomy' => 'actor',
        'field'    => 'id',
        'terms'    => array( 103, 115, 206 ),
        'operator' => 'NOT IN'
    );
 }

$args = array(
    'post_type' => 'post',
    'tax_query' => $tax_query,
);

$query = new WP_Query( $args );

where $bActor and $bMovieGenre are constructed from the user input.

In general, if your user input array is like:

$selected = array( 
    array( 'taxonomy' => 'movie_genre' , 
           'terms'    => array( 'action' , 'comedy') ,
           'field'    => 'slug' ,
           'operator' => 'IN' ,
    ),
    array( 'taxonomy' => 'actor' , 
           'terms'    => array( 103, 115, 206 ) ,
           'field'    => 'slug' ,
           'operator' => 'NOT IN' ,
    ),
);

then you can try this to construct the dynamic taxonomy query :

$tax_query = array( 'relation' => 'AND' );

foreach( $selected as $sel ){

    $tax_query[] = array( 
                      'taxonomy' => $sel['taxonomy'] , 
                      'terms'    => $sel['terms'] , 
                      'field'    => $sel['field'] ,
                      'operator' => $sel['operator'] ,
                   );
}

or just

$tax_query = array( 'relation' => 'AND' );

foreach( $selected as $sel ){

    $tax_query[] = $sel; 

}