\Groundhogg\Campaign

📅 Published on

📝 Last updated

Documentation

»

Classes

»

\Groundhogg\Campaign

extends Base_Object

Represents a campaign — a grouping label that can be applied to emails and broadcasts to organise sends for reporting purposes.

Methods

MethodReturnsDescription
get_id()intReturns the campaign ID.
get_name()stringReturns the campaign name.
get_slug()stringReturns the campaign slug.
get_description()stringReturns the campaign description.
is_public()boolReturns true if the campaign is publicly visible.

Usage

Here’s a pseudo code example for a hypothetical campaign reporting integration.

<?php

/**
 * Get the name of a campaign by ID, with a safe fallback.
 *
 * @param int $campaign_id
 *
 * @return string
 */
function my_plugin_get_campaign_name( $campaign_id ) {

    $campaign = new \Groundhogg\Campaign( $campaign_id );

    if ( ! $campaign->exists() ) {
        return 'Unknown campaign';
    }

    return $campaign->get_name();
}

Was this helpful?

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