groundhogg/admin/contacts/register_info_cards

πŸ“… Published on

πŸ“ Last updated

Documentation

Β»

Action Hooks

Β»

groundhogg/admin/contacts/register_info_cards

Fires when Groundhogg registers the info cards shown in the right sidebar of the contact record. Hook here to add your own panels to the contact edit screen.

do_action( 'groundhogg/admin/contacts/register_info_cards', $info_cards );

You will receive the Info_Cards registry instance.

Example

add_action( 'groundhogg/admin/contacts/register_info_cards', 'my_extension_register_info_card' );

/**
 * Add an order history card to the contact record sidebar.
 *
 * @param \Groundhogg\Admin\Contacts\Info_Cards $info_cards
 *
 * @return void
 */
function my_extension_register_info_card( $info_cards ) {
    $info_cards->register( 'my_extension_orders', [
        'label'    => 'Order History',
        'callback' => function( $contact ) {
            $orders = my_extension_get_orders( $contact->get_email() );

            if ( empty( $orders ) ) {
                echo 'No orders found.';
                return;
            }

            echo '';
            foreach ( $orders as $order ) {
                echo '#' . esc_html( $order->id ) . ' β€” ' . esc_html( $order->total ) . '';
            }
            echo '';
        },
    ] );
}

Was this helpful?

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