MS_Model_Communication_Registration_Free

Communication model - registration for free membership.

Defined (1)

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

/app/model/communication/class-ms-model-communication-registration-free.php  
  1. class MS_Model_Communication_Registration_Free extends MS_Model_Communication_Registration { 
  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_FREE; 
  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 free 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. __( 'Thanks for subscribing to our free <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.  
  62. $html = sprintf( 
  63. '<h2>%1$s</h2><br /><br />%2$s<br /><br />%3$s',  
  64. $subject,  
  65. $body_notice,  
  66. $body_account 
  67. ); 
  68.  
  69. return apply_filters( 
  70. 'ms_model_communication_registration_get_default_message',  
  71. $html 
  72. ); 
  73.  
  74. /** 
  75. * Process communication registration. 
  76. * @since 1.0.0 
  77. */ 
  78. public function process_communication( $event, $subscription ) { 
  79. $membership = $subscription->get_membership(); 
  80.  
  81. // Only process Free memberships here! 
  82. // Email for paid memberships is in MS_Model_Communiction_Registration 
  83. if ( ! $membership->is_free() ) { return; } 
  84.  
  85. do_action( 
  86. 'ms_model_communication_registration_process_before',  
  87. $subscription,  
  88. $event,  
  89. $this 
  90. ); 
  91.  
  92. $this->send_message( $subscription ); 
  93.  
  94. do_action( 
  95. 'ms_model_communication_registration_process_after',  
  96. $subscription,  
  97. $event,  
  98. $this 
  99. );