\Groundhogg\Classes\Note

📅 Published on

📝 Last updated

Documentation

»

Classes

»

\Groundhogg\Classes\Note

extends Base_Object

Represents a note attached to a Groundhogg object — typically a contact. Notes can be added by users, system processes, or automations. The Task class extends Note and adds due-date and completion tracking.

Methods

MethodReturnsDescription
get_owner_id()intReturns the user ID of who created the note.
get_associated_object()Base_Object|falseReturns the object this note is attached to.
create( $data = [] )static|falseCreates and saves the note.
get_as_array()arrayReturns a serialisable representation of the note.

Usage

Here’s a pseudo code example for a hypothetical CRM activity logging integration.

<?php

add_action( 'my_plugin_meeting_logged', 'my_plugin_add_meeting_note', 10, 2 );

/**
 * Add a note to a contact when a meeting is logged.
 *
 * @param string $contact_email
 * @param string $meeting_summary
 *
 * @return void
 */
function my_plugin_add_meeting_note( $contact_email, $meeting_summary ) {

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

    if ( ! $contact ) {
        return;
    }

    $contact->add_note(
        $meeting_summary,
        'user',
        get_current_user_id()
    );
}

Was this helpful?

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