I am trying to alter views filters with hook_views_query_alter like
function custom_views_query_alter(&$view, &$query) {
foreach($query->where[1]['conditions'] as $idx => $condition) {
dpr($condition);
}
}
And below is the output I get from DPR function
Array
(
[field] => node.status
[value] => 1
[operator] => =
)
Array
(
[field] => node.type
[value] => Array
(
[0] => pricing
)
[operator] => in
)
Array
(
[field] => DatabaseCondition Object
(
[conditions:protected] => Array
(
[#conjunction] => AND
[0] => Array
(
[field] => field_data_field_zip_range.field_zip_range_from
[value] => 65000
[operator] => <=
)
[1] => Array
(
[field] => field_data_field_zip_range.field_zip_range_to
[value] => 65000
[operator] => >=
)
)
[arguments:protected] => Array
(
)
[changed:protected] => 1
[queryPlaceholderIdentifier:protected] =>
)
[value] =>
[operator] =>
)
So the first 2 filters are not a problem, you just edit the field and you set new values. Problem is the DatabaseCondition Object with this conditions:protected part. I just don’t have a clue how to change values there.
There was similar questions here views hook query alter but it was not solved. It only solves problems for first 2 filters and doesn’t do anything for DatabaseCondition Object.