1

I am fetching individual contacts using the following:

function get_member($id) {
 $member = array();
 require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/civicrm/civicrm.settings.php';
 require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/civicrm/civicrm/CRM/Core/Config.php';
 $config = CRM_Core_Config::singleton( );
 require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/civicrm/civicrm/api/api.php';
 $contact = civicrm_api('Contact','Get',array('contact_id' => $id, 'version' =>3));
 if ($contact) {
    $member = $contact['values'][$id];
    $member['membership'] = civicrm_membership_contact_get($id);
 }  
 return $member;
}

function civicrm_membership_contact_get($contact) {
  $params = array('contact_id' => $contact);
  try{
    $result = civicrm_api3('Membership', 'get', $params);
    $id = $result['id'];
    return $result['values'][$id];
  } catch (CiviCRM_API3_Exception $e) {
    $errorMessage = $e->getMessage();
    $errorCode = $e->getErrorCode();
    $errorData = $e->getExtraParams();
    return array(
      'error' => $errorMessage,
      'error_code' => $errorCode,
      'error_data' => $errorData,
    );
  }

}

The values array returned has all of my name fields, address fields, job title, employer, email, region... but not my website URL. Screenshot is of the actual contact entry in the Civi admin.

How do I get the Website URL in my data?

admin screenshot

1

According to the API explorer, the Contact Entity does not return the website information. To include that data, you would have to use a GET action on the Website entity. See the example at (your site)/civicrm/api#examples for the fields the Website entity can return.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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