MS_Model_Communication_Registration

Communication model - registration.

Defined (1)

The class is defined in the following location(s).

/app/model/communication/class-ms-model-communication-registration.php  
  1. class MS_Model_Communication_Registration extends MS_Model_Communication { 
  2.  
  3. /** 
  4. * Add action to credit card expire event. 
  5. * Related Action Hooks: 
  6. * - ms_model_event_paid 
  7. * @since 1.0.0 
  8. * @var string The communication type. 
  9. */ 
  10. protected $type = self::COMM_TYPE_REGISTRATION; 
  11.  
  12. /** 
  13. * Get communication description. 
  14. * @since 1.0.0 
  15. * @return string The description. 
  16. */ 
  17. public function get_description() { 
  18. return __( 
  19. 'Sent when a member completes the signup for a paid membership.', 'membership2' 
  20. ); 
  21.  
  22. /** 
  23. * Communication default communication. 
  24. * @since 1.0.0 
  25. */ 
  26. public function reset_to_default() { 
  27. parent::reset_to_default(); 
  28.  
  29. $this->subject = sprintf( 
  30. __( 'Confirmation of your membership at %s', 'membership2' ),  
  31. self::COMM_VAR_BLOG_NAME 
  32. ); 
  33. $this->message = self::get_default_message(); 
  34. $this->enabled = false; 
  35.  
  36. do_action( 
  37. 'ms_model_communication_reset_to_default_after',  
  38. $this->type,  
  39. $this 
  40. ); 
  41.  
  42. /** 
  43. * Get default email message. 
  44. * @since 1.0.0 
  45. * @return string The email message. 
  46. */ 
  47. public static function get_default_message() { 
  48. $subject = sprintf( 
  49. __( 'Hi %1$s, ', 'membership2' ),  
  50. self::COMM_VAR_USERNAME 
  51. ); 
  52. $body_notice = sprintf( 
  53. __( 'Great, you are now subscribed to the <strong>%1$s</strong> Membership at %2$s!', 'membership2' ),  
  54. self::COMM_VAR_MS_NAME,  
  55. self::COMM_VAR_BLOG_NAME 
  56. ); 
  57. $body_account = sprintf( 
  58. __( 'You can review and edit your membership details here: %1$s', 'membership2' ),  
  59. self::COMM_VAR_MS_ACCOUNT_PAGE_URL 
  60. ); 
  61. $body_invoice = __( 'Here are your latest payment information for your subscription:', 'membership2' ); 
  62.  
  63. $html = sprintf( 
  64. '<h2>%1$s</h2><br /><br />%2$s<br /><br />%3$s<br /><br />%4$s<br /><br />%5$s',  
  65. $subject,  
  66. $body_notice,  
  67. $body_account,  
  68. $body_invoice,  
  69. self::COMM_VAR_MS_INVOICE 
  70. ); 
  71.  
  72. return apply_filters( 
  73. 'ms_model_communication_registration_get_default_message',  
  74. $html 
  75. ); 
  76.  
  77. /** 
  78. * Process communication registration. 
  79. * @since 1.0.0 
  80. */ 
  81. public function process_communication( $event, $subscription ) { 
  82. $membership = $subscription->get_membership(); 
  83.  
  84. // Only process Paid memberships here! 
  85. // Email for free memberships is in MS_Model_Communiction_Registration_Free 
  86. if ( $membership->is_free() ) { return; } 
  87.  
  88. do_action( 
  89. 'ms_model_communication_registration_process_before',  
  90. $subscription,  
  91. $event,  
  92. $this 
  93. ); 
  94.  
  95. $this->send_message( $subscription ); 
  96.  
  97. do_action( 
  98. 'ms_model_communication_registration_process_after',  
  99. $subscription,  
  100. $event,  
  101. $this 
  102. );