groundhogg/admin/contact/save

πŸ“… Published on

πŸ“ Last updated

Documentation

Β»

Action Hooks

Β»

groundhogg/admin/contact/save

Fires after a contact record has been saved from the admin edit screen. All standard fields and meta have already been updated.

do_action( 'groundhogg/admin/contact/save', $contact_id, $contact );

You will receive the contact ID as an integer and the Contact object.

Example

add_action( 'groundhogg/admin/contact/save', 'my_extension_save_custom_field', 10, 2 );

/**
 * Save a custom admin field when a contact is saved.
 *
 * @param int                  $contact_id
 * @param \Groundhogg\Contact $contact
 *
 * @return void
 */
function my_extension_save_custom_field( $contact_id, $contact ) {
    if ( isset( $_POST['my_extension_account_tier'] ) ) {
        $contact->update_meta(
            'account_tier',
            sanitize_text_field( $_POST['my_extension_account_tier'] )
        );
    }
}

Was this helpful?

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