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

  1. <?php 
  2. /** 
  3. * Communication model - registration for free membership. 
  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_Free extends MS_Model_Communication_Registration { 
  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_FREE; 
  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 free 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. __( 'Thanks for subscribing to our free <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.  
  77. $html = sprintf( 
  78. '<h2>%1$s</h2><br /><br />%2$s<br /><br />%3$s',  
  79. $subject,  
  80. $body_notice,  
  81. $body_account 
  82. ); 
  83.  
  84. return apply_filters( 
  85. 'ms_model_communication_registration_get_default_message',  
  86. $html 
  87. ); 
  88.  
  89. /** 
  90. * Process communication registration. 
  91. * 
  92. * @since 1.0.0 
  93. */ 
  94. public function process_communication( $event, $subscription ) { 
  95. $membership = $subscription->get_membership(); 
  96.  
  97. // Only process Free memberships here! 
  98. // Email for paid memberships is in MS_Model_Communiction_Registration 
  99. if ( ! $membership->is_free() ) { return; } 
  100.  
  101. do_action( 
  102. 'ms_model_communication_registration_process_before',  
  103. $subscription,  
  104. $event,  
  105. $this 
  106. ); 
  107.  
  108. $this->send_message( $subscription ); 
  109.  
  110. do_action( 
  111. 'ms_model_communication_registration_process_after',  
  112. $subscription,  
  113. $event,  
  114. $this 
  115. ); 
.