Skip to content

Leads

Functions for working with listing leads (customer enquiries).

See the Lead object reference for all methods and properties available on the returned object.


Functions

dms_get_lead( int $lead_id ): Lead

Retrieves a single lead by its ID.

Parameters

Name Type Default Description
$lead_id int - The lead ID

Returns - Lead

Example

$lead = dms_get_lead( 10 );

echo esc_html( $lead->get_name() );
echo esc_html( $lead->get_email() );
echo esc_html( $lead->get_phone() );

dms_get_all_leads( int $type_id, array $args = [] ): array

Returns all leads for a given inventory type.

Parameters

Name Type Default Description
$type_id int - The inventory type ID
$args array [] Optional filter/query args

Returns - Lead[]

Example

$leads = dms_get_all_leads( 1 );

foreach ( $leads as $lead ) {
    echo esc_html( $lead->get_name() ) . ' - ' . esc_html( $lead->get_email() );
}

dms_count_all_leads( int $type_id, array $args = [] ): int

Returns a count of all leads for a given inventory type without loading full Lead objects.

Parameters

Name Type Default Description
$type_id int - The inventory type ID
$args array [] Optional filter/query args

Returns - int

Example

$count = dms_count_all_leads( 1 );

echo sprintf( '%d total leads', $count );

dms_get_leads_for_listing( int $listing_id ): array

Returns all leads attached to a single listing, newest first.

Parameters

Name Type Default Description
$listing_id int - The listing's post ID

Returns - Lead[] - ordered by creation date, newest first. Empty array if the listing has no leads.

Example

$leads = dms_get_leads_for_listing( $post_id );

foreach ( $leads as $lead ) {
    echo esc_html( $lead->get_name() ) . ' - ' . esc_html( $lead->get_email() ) . ' - ' . esc_html( $lead->get_phone() );
}

dms_get_follow_up_leads(): array

Returns all leads that have a follow-up date within the next 7 days.

Returns - Lead[]

Example

$follow_ups = dms_get_follow_up_leads();

foreach ( $follow_ups as $lead ) {
    echo esc_html( $lead->get_name() ) . ' - Follow up: ' . esc_html( $lead->follow_up_date );
}

dms_get_lead_outcomes(): array

Returns the registered lead outcome options as a slug => label array. Filterable via the dms_lead_outcomes hook.

Returns - array

Example

$outcomes = dms_get_lead_outcomes();
// e.g. [ 'pending' => 'Pending', 'deal_closed' => 'Deal closed', ... ]

Built-in outcomes: pending, scheduled_appointment, test_drive, deal_closed, lost.


dms_get_lead_statuses(): array

Returns the registered lead status options as a slug => label array. Filterable via the dms_lead_statuses hook.

Returns - array

Example

$statuses = dms_get_lead_statuses();
// e.g. [ 'new' => 'New', 'contacted' => 'Contacted', ... ]

Built-in statuses: new, contacted, working, won, lost.