[Documentation](https://groundhogg.io/documentation/) » [Functions](https://groundhogg.io/documentation/#doc-functions)

# get_contactdata

Published Tuesday, June 9, 2026 · Last updated Tuesday, June 9, 2026

The primary helper for retrieving a contact record. Pass a contact ID, email address, or WordPress user ID and get back a `Contact` object. If called with no arguments, it returns the *current contact* — first checking the event queue (during funnel processing), then the tracking cookie (during frontend requests). Returns `false` if no contact is found.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `$contact_id_or_email` | `mixed` | A contact ID (int), email address (string), or an existing `Contact` object (returned as-is). Defaults to `false`, which triggers auto-detection of the current contact. |
| `$by_user_id` | `bool` | When `true`, treats the first argument as a WordPress user ID instead of a contact ID. Default `false`. |

## Return value

`Contact|false` — A `Contact` object on success, or `false` if not found. Results are statically cached for the duration of the request.

## Usage

```

$contact = \Groundhogg\get_contactdata( 'jane@example.com' ); // by email
$contact = \Groundhogg\get_contactdata( 42 );                  // by contact ID
$contact = \Groundhogg\get_contactdata( get_current_user_id(), true ); // by WP user ID
$contact = \Groundhogg\get_contactdata(); // auto-detect current contact
```

## Example

Here’s a pseudo code example using `get_contactdata()` inside a custom integration.

```

add_action( 'my_plugin_event', 'my_plugin_handle_event' );

/**
 * Look up the contact and apply a tag when a custom event fires.
 *
 * @param string $email
 *
 * @return void
 */
function my_plugin_handle_event( $email ) {

    $contact = \Groundhogg\get_contactdata( $email );

    if ( ! $contact ) {
        return;
    }

    $contact->apply_tag( 'my-plugin-event' );
}
```
