groundhogg/preferences/manage/preferences_updated

πŸ“… Published on

πŸ“ Last updated

Documentation

Β»

Action Hooks

Β»

groundhogg/preferences/manage/preferences_updated

Fires after a contact updates their marketing preference from the manage-preferences page. Use this to sync the change to external platforms.

do_action( 'groundhogg/preferences/manage/preferences_updated', $contact, $preference );

You will receive the Contact object as the first argument and the new preference value as a string in the second.

Example

add_action( 'groundhogg/preferences/manage/preferences_updated', 'my_extension_sync_preference', 10, 2 );

/**
 * Sync the updated preference to an external email platform.
 *
 * @param \Groundhogg\Contact $contact
 * @param string               $preference
 *
 * @return void
 */
function my_extension_sync_preference( $contact, $preference ) {
    my_extension_api_request( 'PATCH', '/subscribers/' . urlencode( $contact->get_email() ), [
        'status' => $preference,
    ] );
}

Was this helpful?

Let us know if this document answered your question. That’s the only way we can improve.