How do I programmatically set contextual filters?
Contextual filters use query string params.  You could hard code these into the URL.  If using a Url object, you can pass a third argument ['query' => ['param1 => 'param1_value',...]].  Try setting a filter and seeing what the URL param name &amp; value is after doing so.

In hook_views_pre_build(), you can also set the filter value directly:

$view-&gt;filter['filter_name']-&gt;value = 'filter_value';


It's helpful to have Xdebug so you can see the names of existing filters.  If you don't have xdebug, try finding the correct filter name in the ->filter property, then find the desired filter value, and put 2 and 2 together.