• LifterLMS
  • Knowledge Base
  • Academy
  • Blog
  • Podcast
  • Contributors
  • My Account

LifterLMS LifterLMS

  • Code Reference
  • REST API
  • LLMS-CLI

Code Reference

Skip to content
Filter by type:
Search
Browse: Home / Code Reference / Classes / LLMS_Email_Engagement / LLMS_Email_Engagement::init()

LLMS_Email_Engagement::init( array $args )

Initialize all variables

Contents

  • Parameters
  • Return
  • Source
  • Related
    • Uses
  • Changelog
  • User Contributed Notes

Parameters #Parameters

$args

(array) (Required) Associative array of engagement args.


Top ↑

Return #Return

(void)


Top ↑

Source #Source

File: includes/emails/class.llms.email.engagement.php

	public function init( $args ) {

		$this->student    = new WP_User( $args['person_id'] );
		$this->email_post = get_post( $args['email_id'] );

		$this->add_merge_data(
			array(
				'{user_login}'    => stripslashes( $this->student->user_login ),
				'{first_name}'    => stripslashes( $this->student->first_name ),
				'{last_name}'     => stripslashes( $this->student->last_name ),
				'{email_address}' => stripslashes( $this->student->user_email ),
				'{site_url}'      => get_permalink( llms_get_page_id( 'myaccount' ) ),
				'{current_date}'  => date_i18n( get_option( 'date_format' ), current_time( 'timestamp' ) ),
			)
		);

		// Setup subject, headline, & body.
		$this->body    = $this->email_post->post_content;
		$this->subject = get_post_meta( $this->email_post->ID, '_llms_email_subject', true );
		$this->heading = get_post_meta( $this->email_post->ID, '_llms_email_heading', true );

		// Setup all the recipients.
		foreach ( array( 'to', 'cc', 'bcc' ) as $type ) {

			$list = get_post_meta( $this->email_post->ID, '_llms_email_' . $type, true );

			// Fall back to student email for existing emails with no definition.
			if ( ! $list && 'to' === $type ) {
				$list = '{student_email}';
			}

			if ( ! $list ) {
				continue;
			}

			foreach ( $this->merge_emails( $list ) as $email ) {
				$this->add_recipient( $email, $type );
			}
		}

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Related #Related

Uses #Uses

Uses
Uses Description
includes/functions/llms.functions.page.php: llms_get_page_id()

Retrieve the WordPress Page ID of a LifterLMS Core Page.

includes/emails/class.llms.email.engagement.php: LLMS_Email_Engagement::merge_emails()

Handles email merge codes that can be used in the to, cc, and bcc fields


Top ↑

Changelog #Changelog

Changelog
Version Description
3.8.0 Unknown.
1.0.0 Introduced.

Top ↑

User Contributed Notes #User Contributed Notes

You must log in before being able to contribute a note or feedback.

© 2014 - 2023 LifterLMS · Privacy Policy · Terms and Conditions

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.