This documentation relates to CiviCRM version 3.2. It's not maintained anymore.
Current version of documentation.

Snippet - how to make the contact ID of logged in user an argument for views

Aller directement à la fin des métadonnées
Aller au début des métadonnées

This page refers to outdated version of CiviCRM. Check current version of documentation.

Documentation Search

CiviCRM 3.2 Documentation

Support and Participation

Developer Resources

CiviCRM book!

Make sure to check out Understanding CiviCRM as well! You can also support this project by ordering a hard copy.

Here's a quick snippet to paste in as a default argument for Views to use the contact ID for the logged in user as an argument. To use this add a field as an argument & choose provide default argument / php code. If you don't see these options it may be a permissions thing

// Make the first argument 1 if not already set
if (!$args[0]) {
  $args[0] = 1;

global $user;
if (module_exists('civicrm')) {
$sql = "SELECT contact_id FROM {civicrm_uf_match} WHERE uf_id = %d";
$args[0] = db_result(db_query($sql,array($user->uid)));

return $args;

  • Aucun

Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.