extends Base_Object
Represents a campaign — a grouping label that can be applied to emails and broadcasts to organise sends for reporting purposes.
Methods
| Method | Returns | Description |
|---|---|---|
get_id() | int | Returns the campaign ID. |
get_name() | string | Returns the campaign name. |
get_slug() | string | Returns the campaign slug. |
get_description() | string | Returns the campaign description. |
is_public() | bool | Returns 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.
