I'm trying to create a link to a CiviCRM-integrated Drupal webform that passes the ID of a contact's employer

I'm trying to use


but the token replacement is blank. [current-user:civicrm-contact:employer-id] also does not work. However, [current-user:civicrm-contact:current-employer] does replace with the name of the current employer.

  • Gosh I didn't even know tokens like that existed. What module is generating them?
    – Coleman
    May 7, 2016 at 18:04
  • and this can't be done without tokens by putting the Contact's ID in the url and setting cid2 to be filtered based on the relationship?
    – petednz - fuzion
    May 8, 2016 at 0:07
  • 1
    The CiviCRM Entity module is where those tokens come from. drupal.org/project/civicrm_entity May 9, 2016 at 19:39
  • Also, I'm trying to use the token to CREATE the value for cid1= Jun 4, 2016 at 18:16

1 Answer 1


We ended up using Markup field in the webform with some PHP code that made a CiviCRM API call:

$params = array(
  'version' => 3,
  'is_active' => 1,
  'sequential' => 1,
  'contact_id_a' => $_SESSION['CiviCRM']['contact_id'],
  'relationship_type_id' => 4,  // Employee Of
$result = civicrm_api('Relationship', 'get', $params);

if ( ! $result['is_error'] ) {
  $employer_id = array_shift($result['values'])['contact_id_b'];

if ( $employer_id ) { ?>
    <input onclick="location.href='/link-to-webform?cid1=<?php echo $employer_id ?>';" type="button" value="Manage Contacts" />
<?php }

I'm going to file an issue on the module.

  • That's very cool! May 9, 2016 at 20:14
  • This will only be correct if there is only 1 employer. If there are multiple employers this will give rather randomly the one that sequential finds first. Sep 15, 2021 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.