Skip to content

Instantly share code, notes, and snippets.

@Greg-Boggs
Created March 4, 2014 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Greg-Boggs/9357106 to your computer and use it in GitHub Desktop.
Save Greg-Boggs/9357106 to your computer and use it in GitHub Desktop.
Programmatically set a Drupal view argument based on the field of the current user.
/**
* @implements hook_views_pre_view().
* @param $view
* @param $display_id
* @param $args
*
* Programmatically set a Drupal view argument based on the field of the current user.
*/
function tng_weekly_view_views_pre_view(&$view, &$display_id, &$args) {
if($view->name == 'training_overview' && $display_id ='weekly_view') {
global $user;
$wrapper = entity_metadata_wrapper('user', $user);
$args[] = $wrapper->field_delta->value();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment