How to get contextual filter in hook_views_query_alter or hook_views_pre_execute? I want to alter contextual filter before executing the sql query of views. Is there any way to get current contextual filter in hook_views_query_alter or hook_views_pre_execute? Or which is the better hook to alter contextual filter for views?
The contextual filters are in $view->args.

$view->args is an array of arguments (contextual filters).

So you can do things like this:

/**
 * Implements hook_views_pre_execute().
 */
function MODULENAME_views_pre_execute(&amp;$view) {
  // Set the first contextual filter value.
  $view-&gt;args[0] = 1;
}