myCRED_Email
Description
This object holds all settings and data relevant to a given email notice along with a set of methods to process or parse emails.
Available since version 1.8
Interacting with Object
This object should be accessed using the mycred_get_email_notice function.
Object properties
Property | Type | Description | |
---|---|---|---|
myCRED_Email Object (
|
|||
public $post_id |
int | The WordPress post object ID for the email notification. | |
public $post |
object | The WordPress post object. | |
public $point_types |
array | An array of point type keys that trigger this email. | |
public $emailnotices |
array | The Email Notice add-on's settings. | |
public $settings |
array | The email notices settings. | |
protected $trigger |
string | The myCRED reference or keyword that triggers this email. | |
public $last_run |
int | Unix timestamp of the last time the email was triggered. | |
)
|
Object Methods
public function __construct( $notice_id = NULL ) {
|
||||
Description: | Constructs the email notice object if provided a valid email notice post object ID. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$notice_id |
int | Yes | The WordPress post object ID. | |
} |
public function save_settings( $setup = array() ) {
|
||||
Description: | Saves the email notice's recipient, from email, from name and reply to field values. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$setup |
array | Yes | An associative array of the settings we want to save. | |
} |
public function get_trigger() {
|
||||
Description: | Retrieves the emails set trigger. Will return an empty string if no trigger is set. Uses the mycred_get_emails_trigger filter. | |||
---|---|---|---|---|
} |
public function set_trigger( $instance = '' ) {
|
||||
Description: | Saves and sets a given instance as the new trigger for this email notice. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$instance |
string | Yes | The keyword or reference (single or comma separated). | |
} |
public function schedule( $event = array(), $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
||||
Description: | Schedules an event of a given point type to be sent later. This method should not be used if emails are not scheduled but sent immediately. Note that this method does not check if the event should trigger an email, that should be done before this method is called. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$event |
array | Yes | The myCRED instance that triggered this email. | |
$point_type |
string | No | The point type key that triggered this email. | |
} |
public function send( $event = array(), $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
||||
Description: | Sends an email based on a given event for a particular point type. Note that this method does not check if the event should trigger an email, that should be done before this method is called. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$event |
array | Yes | The myCRED instance that triggered this email. | |
$point_type |
string | No | The point type key that triggered this email. | |
} |
public function update_last_run( $timestamp = NULL ) {
|
||||
Description: | Saves the unix timestamp that indicates when the email notice was last sent. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$timestamp |
int | Yes | A UNIX timestamp. | |
} |
public function get_email_styling() {
|
||||
Description: | Returns the CSS styling set for this email notice. If the email notice has no CSS styling set, the CSS styling set in the add-on settings is returned instead. | |||
---|---|---|---|---|
} |
public function get_recipients( $user = '', $admin = '' ) {
|
||||
Description: | Returns an array of email addresses that the email should be sent to based on the recipient option. |
|||
---|---|---|---|---|
Variable | Type | Required | Description | |
$user |
string | Yes | The users email address. | |
$admin |
string | Yes | The administrators email address. | |
} |
public function get_headers() {
|
||||
Description: | Returns the email headers that should accompany the email. | |||
---|---|---|---|---|
} |
public function get_subject( $event = array(), $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
||||
Description: | Returns the emails subject (post title). Note that the subject field is parsed for general and amount related template tags. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$event |
array | Yes | The event that triggered this email. This is used to render template tags. | |
$point_type |
string | No | The point type ID that triggered the email. | |
} |
public function get_body( $event = array(), $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
||||
Description: | Returns the emails body (post content). Note that the subject field is parsed for general and amount related template tags. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$event |
array | Yes | The event that triggered this email. This is used to render template tags. | |
$point_type |
string | No | The point type ID that triggered the email. | |
} |
public function get_message( $event = array(), $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
||||
Description: | Returns the emails body (post content). Unlike the get_body() method, this method renders the content if the email is set to use HTML format. If you know that all emails are sent in plain text format, you can use the get_body() method instead. If emails are both plain text and HTML, it is recommended that you use this method instead. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$event |
array | Yes | The event that triggered this email. This is used to render template tags. | |
$point_type |
string | No | The point type ID that triggered the email. | |
} |
Object Example
myCRED_Email Object ( [post_id] => 140 [post] => WP_Post Object ( [ID] => 140 [post_author] => 2 [post_date] => 2017-06-27 13:41:00 [post_date_gmt] => 2017-06-27 11:41:00 [post_content] => Congrats! You have successfully deposited %amount% coins into your account! [post_title] => Gaining Coins [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => gaining-coins [to_ping] => [pinged] => [post_modified] => 2017-09-27 22:19:53 [post_modified_gmt] => 2017-09-27 20:19:53 [post_content_filtered] => [post_parent] => 0 [guid] => http://yourwebsite.com/?post_type=mycred_email_notice&p=140 [menu_order] => 0 [post_type] => mycred_email_notice [post_mime_type] => [comment_count] => 0 [filter] => raw ) [point_types] => Array ( [0] => mycred_default [1] => mycred_credit ) [emailnotices] => Array ( [use_html] => 0 [filter] => Array ( [subject] => 1 [content] => 1 ) [from] => Array ( [name] => The Laboratory [email] => support@website.com [reply_to] => support@website.com ) [content] => [styling] => [send] => [override] => 0 ) [settings] => Array ( [recipient] => user [senders_name] => The Laboratory [senders_email] => donotreply@website.com [reply_to] => donotreply@website.com ) [trigger:protected] => buy_scratch_card [last_run] => 1505314880 )