/app/model/communication/class-ms-model-communication-registration.php

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