Skip to content

Instantly share code, notes, and snippets.

@AnadarProSvcs
Last active December 20, 2023 13:47
Show Gist options
  • Save AnadarProSvcs/8e1c424a4707244aaf868e0611898ac0 to your computer and use it in GitHub Desktop.
Save AnadarProSvcs/8e1c424a4707244aaf868e0611898ac0 to your computer and use it in GitHub Desktop.
A breakdown of the Paid Memberships Pro Email Object #PMPro #pmpro

PMPro Email Object Reference

Overview

The PMPro Email object in Paid Memberships Pro is used for managing and sending emails within the PMPro system. It includes a variety of properties and methods that allow for customization and control over the email sending process.

Properties

1. email

  • Type: String
  • Description: The email address of the recipient.

2. template

  • Type: String
  • Description: The name of the email template being used.

3. subject

  • Type: String
  • Description: The subject line of the email.

4. body

  • Type: String
  • Description: The body content of the email.

5. headers

  • Type: Array/String
  • Description: Additional headers for the email, like content type.

6. attachments

  • Type: Array
  • Description: File paths of attachments to be included in the email.

7. data

  • Type: Array/Object
  • Description: Additional data relevant to the email.
  • Example Elements:
    • subject: The subject of the email.
    • name: The name of the recipient.
    • sitename: The name of the site or organization.
    • membership_id: ID of the membership.
    • membership_level_name: Name of the membership level.
    • membership_cost: Cost of the membership.
    • login_url: URL for the user to log in.
    • user_email: Email address of the user.
    • invoice_id: ID of the invoice.
    • invoice_total: Total amount of the invoice.
    • billing_name: Name of the billing contact.
    • billing_address: Billing address.
    • cardtype: Type of card used for payment.
    • expirationmonth: Expiration month of the card.
    • instructions: Specific instructions or messages.
    • invoice_link: Link to the invoice.
    • donation: Donation amount, if applicable.

Methods

1. send()

  • Returns: Boolean
  • Description: Sends the email. Returns true if successful.

2. template()

  • Parameters: template_name (String)
  • Returns: Void
  • Description: Sets the email template to be used.

3. getTemplate()

  • Parameters: None
  • Returns: String
  • Description: Returns the name of the current email template.

4. applyTemplate()

  • Parameters: None
  • Returns: Void
  • Description: Applies the selected template to the email.

5. setBody()

  • Parameters: body (String)
  • Returns: Void
  • Description: Sets the body of the email.

6. setSubject()

  • Parameters: subject (String)
  • Returns: Void
  • Description: Sets the subject of the email.

7. addAttachment()

  • Parameters: attachment (String)
  • Returns: Void
  • Description: Adds an attachment to the email.

Usage Example

$email = new PMProEmail();
$email->email = "example@example.com";
$email->subject = "Welcome to Our Service!";
$email->body = "This is an example email body.";
$email->data = ['membership_level' => 'Gold', 'expiry_date' => '2023-12-31'];
$email->send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment