Simple Membership - Version 4.1.8

Version Description

  • Improved the view debug log operation to check if the file exists before trying to open the file. If the file doesn't exist, it will show a message to reset the debug file.
Download this release

Release Info

Developer mra13
Plugin Icon 128x128 Simple Membership
Version 4.1.8
Comparing to
See all releases

Code changes from version 4.1.6 to 4.1.8

classes/class.simple-wp-membership.php CHANGED
@@ -321,7 +321,13 @@ class SimpleWpMembership {
321
  SwpmLog::log_auth_debug("Triggering swpm_after_login hook.", true);
322
  do_action('swpm_after_login');
323
  if (!SwpmUtils::is_ajax()) {
324
- $redirect_url = apply_filters('swpm_after_login_redirect_url', SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL);
 
 
 
 
 
 
325
  wp_redirect($redirect_url);
326
  exit(0);
327
  }
@@ -717,6 +723,9 @@ class SimpleWpMembership {
717
  wp_register_script('swpm.validationEngine-localization', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm.validationEngine-localization.js', array('jquery'), SIMPLE_WP_MEMBERSHIP_VER);
718
  wp_register_script('swpm.password-toggle', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm.password-toggle.js', array('jquery'), SIMPLE_WP_MEMBERSHIP_VER);
719
 
 
 
 
720
  }
721
 
722
  public static function enqueue_validation_scripts($add_params = array()) {
321
  SwpmLog::log_auth_debug("Triggering swpm_after_login hook.", true);
322
  do_action('swpm_after_login');
323
  if (!SwpmUtils::is_ajax()) {
324
+ //Redirection after login to make sure the page loads with all the correct variables set everywhere.
325
+ $redirect_url = SwpmMiscUtils::get_current_page_url();
326
+ if(empty($redirect_url)){
327
+ $redirect_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL;
328
+ }
329
+ $redirect_url = apply_filters('swpm_after_login_redirect_url', $redirect_url);
330
+ SwpmLog::log_auth_debug("After triggering the default swpm_after_login_redirect_url hook. Redirect URL: ". $redirect_url, true);
331
  wp_redirect($redirect_url);
332
  exit(0);
333
  }
723
  wp_register_script('swpm.validationEngine-localization', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm.validationEngine-localization.js', array('jquery'), SIMPLE_WP_MEMBERSHIP_VER);
724
  wp_register_script('swpm.password-toggle', SIMPLE_WP_MEMBERSHIP_URL . '/js/swpm.password-toggle.js', array('jquery'), SIMPLE_WP_MEMBERSHIP_VER);
725
 
726
+ //Stripe libraries
727
+ wp_register_script("swpm.stripe", "https://js.stripe.com/v3/", array("jquery"), SIMPLE_WP_MEMBERSHIP_VER);
728
+ wp_register_style("swpm.stripe.style", "https://checkout.stripe.com/v3/checkout/button.css", array(), SIMPLE_WP_MEMBERSHIP_VER);
729
  }
730
 
731
  public static function enqueue_validation_scripts($add_params = array()) {
classes/class.swpm-front-registration.php CHANGED
@@ -406,6 +406,9 @@ class SwpmFrontRegistration extends SwpmRegistration {
406
  }
407
  $settings = SwpmSettings::get_instance();
408
  $password = wp_generate_password();
 
 
 
409
 
410
  $password_hash = SwpmUtils::encrypt_password( trim( $password ) ); //should use $saned??;
411
  $wpdb->update( $wpdb->prefix . 'swpm_members_tbl', array( 'password' => $password_hash ), array( 'member_id' => $user->member_id ) );
406
  }
407
  $settings = SwpmSettings::get_instance();
408
  $password = wp_generate_password();
409
+
410
+ //Trigger a hook
411
+ $password = apply_filters( 'swpm_password_reset_generated_pass', $password );
412
 
413
  $password_hash = SwpmUtils::encrypt_password( trim( $password ) ); //should use $saned??;
414
  $wpdb->update( $wpdb->prefix . 'swpm_members_tbl', array( 'password' => $password_hash ), array( 'member_id' => $user->member_id ) );
classes/class.swpm-log.php CHANGED
@@ -33,8 +33,19 @@ class SwpmLog {
33
  }
34
  self::gen_log_file_names();
35
  $log_file = 'd' === $type ? self::$log_file : self::$log_auth_file;
 
 
 
 
 
 
 
36
 
37
- $fp = fopen( SIMPLE_WP_MEMBERSHIP_PATH . $log_file, 'r' );
 
 
 
 
38
  header( 'Content-Type: text/plain' );
39
  fpassthru( $fp );
40
  die;
33
  }
34
  self::gen_log_file_names();
35
  $log_file = 'd' === $type ? self::$log_file : self::$log_auth_file;
36
+ $log_file_full_path = SIMPLE_WP_MEMBERSHIP_PATH . $log_file;
37
+
38
+ if ( ! file_exists( $log_file_full_path ) ) {
39
+ $log_file_missing_msg = '<p>Could not find the log file. Reset the log file from the settings menu to regenerate it then try again. You can find the Reset Debug Log option in the Debug Settings section.</p>';
40
+ $log_file_missing_msg .= '<p>If it still fails to open the log file after that, check if the plugin directory (' . SIMPLE_WP_MEMBERSHIP_PATH . ') is writeable on your server.</p>';
41
+ wp_die( $log_file_missing_msg );
42
+ }
43
 
44
+ //Open the log file
45
+ $fp = fopen( $log_file_full_path, 'rb' );
46
+ if ( ! $fp ) {
47
+ wp_die( 'Can\'t open the log file.' );
48
+ }
49
  header( 'Content-Type: text/plain' );
50
  fpassthru( $fp );
51
  die;
classes/class.swpm-members.php CHANGED
@@ -120,7 +120,7 @@ class SwpmMembers extends WP_List_Table {
120
  if ( ! empty( $s ) ) {
121
  $s = sanitize_text_field( $s );
122
  $s = trim( $s ); //Trim the input
123
- $s = esc_attr( $s );
124
  $filters[] = "( user_name LIKE '%" . strip_tags( $s ) . "%' "
125
  . " OR first_name LIKE '%" . strip_tags( $s ) . "%' "
126
  . " OR last_name LIKE '%" . strip_tags( $s ) . "%' "
120
  if ( ! empty( $s ) ) {
121
  $s = sanitize_text_field( $s );
122
  $s = trim( $s ); //Trim the input
123
+ $s = esc_sql( $s );
124
  $filters[] = "( user_name LIKE '%" . strip_tags( $s ) . "%' "
125
  . " OR first_name LIKE '%" . strip_tags( $s ) . "%' "
126
  . " OR last_name LIKE '%" . strip_tags( $s ) . "%' "
classes/class.swpm-self-action-handler.php CHANGED
@@ -13,6 +13,9 @@ class SwpmSelfActionHandler {
13
 
14
  add_filter('swpm_after_logout_redirect_url', array(&$this, 'handle_after_logout_redirection'));
15
  add_filter('swpm_auth_cookie_expiry_value', array(&$this, 'handle_auth_cookie_expiry_value'));
 
 
 
16
  }
17
 
18
  public function handle_auth_cookie_expiry_value($expire){
@@ -107,4 +110,154 @@ class SwpmSelfActionHandler {
107
 
108
  }
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }
13
 
14
  add_filter('swpm_after_logout_redirect_url', array(&$this, 'handle_after_logout_redirection'));
15
  add_filter('swpm_auth_cookie_expiry_value', array(&$this, 'handle_auth_cookie_expiry_value'));
16
+
17
+ add_action("swpm_do_init_time_tasks_front_end", array(&$this, 'handle_whitelist_blacklist_registration'));
18
+ add_action("swpm_before_login_request_is_processed", array(&$this, 'handle_whitelist_blacklist_login'));
19
  }
20
 
21
  public function handle_auth_cookie_expiry_value($expire){
110
 
111
  }
112
 
113
+ public function handle_whitelist_blacklist_registration()
114
+ {
115
+ //Check if registration form has been submitted
116
+ if ( !SwpmUtils::is_rego_form_submitted() ){
117
+ return;
118
+ }
119
+
120
+ //Get the email address
121
+ $user_email = '';
122
+ if ( isset ($_POST["email"]) ){
123
+ //Core plugin's rego form
124
+ $user_email = SwpmMemberUtils::get_sanitized_email($_POST["email"]);
125
+ } else {
126
+ $fb_email = SwpmUtils::get_fb_rego_email_field_value();
127
+ if ( !empty($fb_email) ){
128
+ //Form builder's rego form
129
+ $user_email = SwpmMemberUtils::get_sanitized_email($fb_email);
130
+ }
131
+ }
132
+ if( empty($user_email) ) {
133
+ return;
134
+ }
135
+
136
+ //Check whitelsting and blacklisting settings
137
+ if(SwpmSettings::get_instance()->get_value( 'enable-whitelisting' )) {
138
+ $is_whitelisted=false;
139
+
140
+ $emailaddress_whitelist = SwpmSettings::get_instance()->get_value( 'whitelist-email-address' );
141
+ if($emailaddress_whitelist) {
142
+ if(SwpmUtils::csv_equal_match($user_email,$emailaddress_whitelist)) {
143
+ $is_whitelisted=true;
144
+ return;
145
+ }
146
+ }
147
+
148
+ $emailaddress_pattern_whitelist = SwpmSettings::get_instance()->get_value( 'whitelist-email-address-pattern' );
149
+ if($emailaddress_pattern_whitelist) {
150
+ if(SwpmUtils::csv_pattern_match($user_email,$emailaddress_pattern_whitelist)) {
151
+ $is_whitelisted=true;
152
+ return;
153
+ }
154
+ }
155
+
156
+ //Trigger a filter hook so it can be overriden from an addon
157
+ $is_whitelisted = apply_filters( 'swpm_email_not_whitelisted_before_registration_block', $is_whitelisted, $user_email);
158
+
159
+ //If whitelisting is enabled and the user email doesn't match any whitelisting rule.
160
+ //Block the registration
161
+ if($is_whitelisted==false) {
162
+ $block_message_whitelist = SwpmSettings::get_instance()->get_value( 'whitelist-block-message' );
163
+ if( !isset($block_message_whitelist) || empty($block_message_whitelist) ) {
164
+ $block_message_whitelist = SwpmUtils::_("The email address you used is not whitelisted on this site.");
165
+ }
166
+
167
+ SwpmLog::log_simple_debug( 'Registration blocked for user: '.$user_email.', as it did not match any whitelisting rule.', true );
168
+ wp_die($block_message_whitelist);
169
+ }
170
+ }
171
+
172
+ if(SwpmSettings::get_instance()->get_value( 'enable-blacklisting' )) {
173
+ $block_message = SwpmSettings::get_instance()->get_value( 'blacklist-block-message' );
174
+ if(!$block_message) {
175
+ $block_message = SwpmUtils::_("The email address you used is blacklisted on this site.");
176
+ }
177
+
178
+ $emailaddress_blacklist = SwpmSettings::get_instance()->get_value( 'blacklist-email-address' );
179
+ if($emailaddress_blacklist) {
180
+ if(SwpmUtils::csv_equal_match($user_email,$emailaddress_blacklist)) {
181
+ SwpmLog::log_simple_debug( 'Login blocked for user: '.$user_email.' from the Blacklist Email Address List.', true );
182
+ wp_die($block_message);
183
+ }
184
+ }
185
+
186
+ $emailaddress_pattern_blacklist = SwpmSettings::get_instance()->get_value( 'blacklist-email-address-pattern' );
187
+ if($emailaddress_pattern_blacklist) {
188
+ if(SwpmUtils::csv_pattern_match($user_email,$emailaddress_pattern_blacklist)) {
189
+ SwpmLog::log_simple_debug( 'Login blocked for user: '.$user_email.' from the Blacklist Email Address Pattern List.', true );
190
+ wp_die($block_message);
191
+ }
192
+ }
193
+ }
194
+ return;
195
+ }
196
+
197
+ public function handle_whitelist_blacklist_login($args)
198
+ {
199
+ $user_email = SwpmMemberUtils::get_sanitized_email($args["username"]);
200
+ if(!$user_email) {
201
+ return;
202
+ }
203
+
204
+ if(SwpmSettings::get_instance()->get_value( 'enable-whitelisting' )) {
205
+ $is_whitelisted=false;
206
+
207
+ $emailaddress_whitelist = SwpmSettings::get_instance()->get_value( 'whitelist-email-address' );
208
+ if($emailaddress_whitelist) {
209
+ if(SwpmUtils::csv_equal_match($user_email,$emailaddress_whitelist)) {
210
+ $is_whitelisted=true;
211
+ return;
212
+ }
213
+ }
214
+
215
+ $emailaddress_pattern_whitelist = SwpmSettings::get_instance()->get_value( 'whitelist-email-address-pattern' );
216
+ if($emailaddress_pattern_whitelist) {
217
+ if(SwpmUtils::csv_pattern_match($user_email,$emailaddress_pattern_whitelist)) {
218
+ $is_whitelisted=true;
219
+ return;
220
+ }
221
+ }
222
+
223
+ //Trigger a filter hook so it can be overriden from an addon
224
+ $is_whitelisted = apply_filters( 'swpm_email_not_whitelisted_before_login_block', $is_whitelisted, $user_email);
225
+
226
+ //If whitelist is enabled and user email doesn't match any whitelist rule.
227
+ //Block the login
228
+ if($is_whitelisted==false) {
229
+ $block_message_whitelist = SwpmSettings::get_instance()->get_value( 'whitelist-block-message' );
230
+ if( !isset($block_message_whitelist) || empty($block_message_whitelist) ) {
231
+ $block_message_whitelist = SwpmUtils::_("The email address you used is not whitelisted on this site.");
232
+ }
233
+
234
+ SwpmLog::log_simple_debug( 'Login blocked for user: '.$user_email.', as it did not match any whitelisting rule.', true );
235
+ wp_die($block_message_whitelist);
236
+ }
237
+ }
238
+
239
+ if(SwpmSettings::get_instance()->get_value( 'enable-blacklisting' )) {
240
+ $block_message = SwpmSettings::get_instance()->get_value( 'blacklist-block-message' );
241
+ if(!$block_message) {
242
+ $block_message = SwpmUtils::_("The email address you used is blacklisted on this site.");
243
+ }
244
+
245
+ $emailaddress_blacklist = SwpmSettings::get_instance()->get_value( 'blacklist-email-address' );
246
+ if($emailaddress_blacklist) {
247
+ if(SwpmUtils::csv_equal_match($user_email,$emailaddress_blacklist)) {
248
+ SwpmLog::log_simple_debug( 'Login blocked for user: '.$user_email.' from the Blacklist Email Address List.', true );
249
+ wp_die($block_message);
250
+ }
251
+ }
252
+
253
+ $emailaddress_pattern_blacklist = SwpmSettings::get_instance()->get_value( 'blacklist-email-address-pattern' );
254
+ if($emailaddress_pattern_blacklist) {
255
+ if(SwpmUtils::csv_pattern_match($user_email,$emailaddress_pattern_blacklist)) {
256
+ SwpmLog::log_simple_debug( 'Login blocked for user: '.$user_email.' from the Blacklist Email Address Pattern List.', true );
257
+ wp_die($block_message);
258
+ }
259
+ }
260
+ }
261
+ return;
262
+ }
263
  }
classes/class.swpm-settings.php CHANGED
@@ -44,7 +44,8 @@ class SwpmSettings {
44
  3 => SwpmUtils::_( 'Email Settings' ),
45
  4 => SwpmUtils::_( 'Tools' ),
46
  5 => SwpmUtils::_( 'Advanced Settings' ),
47
- 6 => SwpmUtils::_( 'Addons Settings' ),
 
48
  );
49
 
50
  //Register the draw tab action hook. It will be triggered using do_action("swpm-draw-settings-nav-tabs")
@@ -888,7 +889,119 @@ class SwpmSettings {
888
  }
889
 
890
  private function tab_6() {
891
- //Register settings sections and fileds for the addon settings tab.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
892
  }
893
 
894
  public static function get_instance() {
@@ -1095,7 +1208,35 @@ class SwpmSettings {
1095
 
1096
  }
1097
 
 
 
1098
  SwpmUtils::e( 'This page allows you to configure some advanced features of the plugin.' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1099
  }
1100
 
1101
  public function advanced_settings_auto_create_swpm_uses_settings_callback() {
@@ -1219,6 +1360,23 @@ class SwpmSettings {
1219
  return $output;
1220
  }
1221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1222
  public function get_value( $key, $default = '' ) {
1223
  if ( isset( $this->settings[ $key ] ) ) {
1224
  return $this->settings[ $key ];
@@ -1287,6 +1445,10 @@ class SwpmSettings {
1287
  include SIMPLE_WP_MEMBERSHIP_PATH . 'views/admin_settings.php';
1288
  break;
1289
  case 6:
 
 
 
 
1290
  //Addon settings
1291
  include SIMPLE_WP_MEMBERSHIP_PATH . 'views/admin_addon_settings.php';
1292
  break;
44
  3 => SwpmUtils::_( 'Email Settings' ),
45
  4 => SwpmUtils::_( 'Tools' ),
46
  5 => SwpmUtils::_( 'Advanced Settings' ),
47
+ 6 => SwpmUtils::_( 'Blacklisting & Whitelisting' ),
48
+ 7 => SwpmUtils::_( 'Addons Settings' ),
49
  );
50
 
51
  //Register the draw tab action hook. It will be triggered using do_action("swpm-draw-settings-nav-tabs")
889
  }
890
 
891
  private function tab_6() {
892
+ //Register settings sections and fields for the blacklisting and whitelisting settings tab.
893
+
894
+ register_setting( 'swpm-settings-tab-6', 'swpm-settings', array( &$this, 'sanitize_tab_6' ) );
895
+
896
+ /* Overview section at the top */
897
+ add_settings_section( 'blacklist-whitelist-settings-overview', SwpmUtils::_( 'Configure Blacklisting & Whitelisting' ), array( &$this, 'blacklist_whitelist_overview_callback' ), 'simple_wp_membership_settings' );
898
+
899
+ /* Whitelisting settings section */
900
+ add_settings_section( 'whitelist-settings', SwpmUtils::_( 'Whitelisting' ), array( &$this, 'whitelist_settings_callback' ), 'simple_wp_membership_settings' );
901
+
902
+ add_settings_field(
903
+ 'enable-whitelisting',
904
+ SwpmUtils::_( 'Enable Whitelisting Feature' ),
905
+ array( &$this, 'checkbox_callback' ),
906
+ 'simple_wp_membership_settings',
907
+ 'whitelist-settings',
908
+ array(
909
+ 'item' => 'enable-whitelisting',
910
+ 'message' => SwpmUtils::_( "When enabled, whitelisting feature will be activated." ),
911
+ )
912
+ );
913
+
914
+ add_settings_field(
915
+ 'whitelist-email-address',
916
+ SwpmUtils::_( 'Email Address Whitelisting' ),
917
+ array( &$this, 'textarea_callback' ),
918
+ 'simple_wp_membership_settings',
919
+ 'whitelist-settings',
920
+ array(
921
+ 'item' => 'whitelist-email-address',
922
+ 'message' => SwpmUtils::_( 'Enter a list (comma separated) of email addresses to whitelist.' ),
923
+ )
924
+ );
925
+
926
+ add_settings_field(
927
+ 'whitelist-email-address-pattern',
928
+ SwpmUtils::_( 'Email Address Pattern Whitelisting' ),
929
+ array( &$this, 'textarea_callback' ),
930
+ 'simple_wp_membership_settings',
931
+ 'whitelist-settings',
932
+ array(
933
+ 'item' => 'whitelist-email-address-pattern',
934
+ 'message' => SwpmUtils::_( 'Enter a list (comma separated) of email addresses pattern to whitelist. Example value: @gooddomain.com, @gmail.com, @yahoo.com' ),
935
+ )
936
+ );
937
+
938
+ add_settings_field(
939
+ 'whitelist-block-message',
940
+ SwpmUtils::_( 'Whitelist Message Customization' ),
941
+ array( &$this, 'textarea_callback' ),
942
+ 'simple_wp_membership_settings',
943
+ 'whitelist-settings',
944
+ array(
945
+ 'item' => 'whitelist-block-message',
946
+ 'message' => SwpmUtils::_( 'Enter the message you want to show to the user when the whitelisted condition is met. Leave it empty to use the default message.' ),
947
+ )
948
+ );
949
+
950
+ /** BLACKLIST SETTINGS **/
951
+ add_settings_section( 'blacklist-settings', SwpmUtils::_( 'Blacklisting' ), array( &$this, 'blacklist_settings_callback' ), 'simple_wp_membership_settings' );
952
+
953
+ add_settings_field(
954
+ 'enable-blacklisting',
955
+ SwpmUtils::_( 'Enable Blacklisting Feature' ),
956
+ array( &$this, 'checkbox_callback' ),
957
+ 'simple_wp_membership_settings',
958
+ 'blacklist-settings',
959
+ array(
960
+ 'item' => 'enable-blacklisting',
961
+ 'message' => SwpmUtils::_( "When enabled, blacklisting feature will be activated." ),
962
+ )
963
+ );
964
+
965
+ add_settings_field(
966
+ 'blacklist-email-address',
967
+ SwpmUtils::_( 'Email Address Blacklisting' ),
968
+ array( &$this, 'textarea_callback' ),
969
+ 'simple_wp_membership_settings',
970
+ 'blacklist-settings',
971
+ array(
972
+ 'item' => 'blacklist-email-address',
973
+ 'message' => SwpmUtils::_( 'Enter a list (comma separated) of email addresses to blacklist.' ),
974
+ )
975
+ );
976
+
977
+ add_settings_field(
978
+ 'blacklist-email-address-pattern',
979
+ SwpmUtils::_( 'Email Address Pattern Blacklisting' ),
980
+ array( &$this, 'textarea_callback' ),
981
+ 'simple_wp_membership_settings',
982
+ 'blacklist-settings',
983
+ array(
984
+ 'item' => 'blacklist-email-address-pattern',
985
+ 'message' => SwpmUtils::_( 'Enter a list (comma separated) of email addresses pattern to blacklist. Example value: @baddomain.com, @crazydomain.com' ),
986
+ )
987
+ );
988
+
989
+ add_settings_field(
990
+ 'blacklist-block-message',
991
+ SwpmUtils::_( 'Blacklist Message Customization' ),
992
+ array( &$this, 'textarea_callback' ),
993
+ 'simple_wp_membership_settings',
994
+ 'blacklist-settings',
995
+ array(
996
+ 'item' => 'blacklist-block-message',
997
+ 'message' => SwpmUtils::_( 'Enter the message you want to show to the user when the blacklisted condition is met. Leave it empty to use the default message.' ),
998
+ )
999
+ );
1000
+ }
1001
+
1002
+ private function tab_7() {
1003
+ //Register settings sections and fields for the addon settings tab.
1004
+
1005
  }
1006
 
1007
  public static function get_instance() {
1208
 
1209
  }
1210
 
1211
+ echo '<div class="swpm-grey-box">';
1212
+ echo '<p>';
1213
  SwpmUtils::e( 'This page allows you to configure some advanced features of the plugin.' );
1214
+ echo '</p>';
1215
+ echo '</div>';
1216
+ }
1217
+
1218
+ public function blacklist_whitelist_overview_callback() {
1219
+ //Show settings updated message when it is updated
1220
+ if ( isset( $_REQUEST['settings-updated'] ) ) {
1221
+ //This status message need to be in the callback function to prevent header sent warning
1222
+ echo '<div id="message" class="updated fade"><p>' . SwpmUtils::_( 'Settings updated!' ) . '</p></div>';
1223
+ }
1224
+
1225
+ echo '<div class="swpm-grey-box">';
1226
+ echo '<p>';
1227
+ SwpmUtils::e( 'This interface lets you configure blacklisting & whitelisting for email addresses. ' );
1228
+ echo '<a href="https://simple-membership-plugin.com/blacklisting-whitelisting-feature/" target="_blank">' . SwpmUtils::_( 'This blacklisting & whitelisting documentation' ) . '</a>';
1229
+ SwpmUtils::e( ' explains how to use this feautre.' );
1230
+ echo '</p>';
1231
+ echo '</div>';
1232
+ }
1233
+
1234
+ public function whitelist_settings_callback() {
1235
+ SwpmUtils::e( 'This section allows you to configure whitelisting settings.' );
1236
+ }
1237
+
1238
+ public function blacklist_settings_callback() {
1239
+ SwpmUtils::e( 'This section allows you to configure blacklisting settings.' );
1240
  }
1241
 
1242
  public function advanced_settings_auto_create_swpm_uses_settings_callback() {
1360
  return $output;
1361
  }
1362
 
1363
+ public function sanitize_tab_6( $input ) {
1364
+ if ( empty( $this->settings ) ) {
1365
+ $this->settings = (array) get_option( 'swpm-settings' );
1366
+ }
1367
+ $output = $this->settings;
1368
+ $output['enable-whitelisting'] = isset( $input['enable-whitelisting'] ) ? esc_attr( $input['enable-whitelisting'] ) : '';
1369
+ $output['whitelist-email-address'] = isset( $input['whitelist-email-address'] ) ? esc_attr( $input['whitelist-email-address'] ) : '';
1370
+ $output['whitelist-email-address-pattern'] = isset( $input['whitelist-email-address-pattern'] ) ? esc_attr( $input['whitelist-email-address-pattern'] ) : '';
1371
+ $output['whitelist-block-message'] = isset( $input['whitelist-block-message'] ) ? esc_attr( $input['whitelist-block-message'] ) : '';
1372
+
1373
+ $output['enable-blacklisting'] = isset( $input['enable-blacklisting'] ) ? esc_attr( $input['enable-blacklisting'] ) : '';
1374
+ $output['blacklist-email-address'] = isset( $input['blacklist-email-address'] ) ? esc_attr( $input['blacklist-email-address'] ) : '';
1375
+ $output['blacklist-email-address-pattern'] = isset( $input['blacklist-email-address-pattern'] ) ? esc_attr( $input['blacklist-email-address-pattern'] ) : '';
1376
+ $output['blacklist-block-message'] = isset( $input['blacklist-block-message'] ) ? esc_attr( $input['blacklist-block-message'] ) : '';
1377
+ return $output;
1378
+ }
1379
+
1380
  public function get_value( $key, $default = '' ) {
1381
  if ( isset( $this->settings[ $key ] ) ) {
1382
  return $this->settings[ $key ];
1445
  include SIMPLE_WP_MEMBERSHIP_PATH . 'views/admin_settings.php';
1446
  break;
1447
  case 6:
1448
+ //Blacklist & whitelist settings
1449
+ include SIMPLE_WP_MEMBERSHIP_PATH . 'views/admin_settings.php';
1450
+ break;
1451
+ case 7:
1452
  //Addon settings
1453
  include SIMPLE_WP_MEMBERSHIP_PATH . 'views/admin_addon_settings.php';
1454
  break;
classes/class.swpm-utils-member.php CHANGED
@@ -327,4 +327,26 @@ class SwpmMemberUtils {
327
  );
328
  SwpmLog::log_simple_debug( 'User role updated.', true );
329
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  }
327
  );
328
  SwpmLog::log_simple_debug( 'User role updated.', true );
329
  }
330
+
331
+ //if a username is provided, it will return sanitized email of the user
332
+ //if no username is found, empty is returned
333
+ public static function get_sanitized_email($username_or_email_address)
334
+ {
335
+ if(is_email($username_or_email_address))
336
+ {
337
+ return sanitize_email($username_or_email_address);
338
+ }
339
+ else{
340
+ $user_row = SwpmMemberUtils::get_user_by_user_name( $username_or_email_address );
341
+
342
+ if ( $user_row ) {
343
+ //found a profile
344
+ return $user_row->email;
345
+ }
346
+ }
347
+ return "";
348
+ }
349
+
350
+
351
+
352
  }
classes/class.swpm-utils-misc.php CHANGED
@@ -781,8 +781,12 @@ class SwpmMiscUtils {
781
 
782
  /**
783
  * Outputs Stripe SCA frontend scripts and styles once
 
784
  */
785
  public static function output_stripe_sca_frontend_scripts_once() {
 
 
 
786
  $out = '';
787
  if ( ! self::$stripe_sca_frontend_scripts_printed ) {
788
  $out .= '<script src="https://js.stripe.com/v3/"></script>';
781
 
782
  /**
783
  * Outputs Stripe SCA frontend scripts and styles once
784
+ * @deprecated
785
  */
786
  public static function output_stripe_sca_frontend_scripts_once() {
787
+
788
+ trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED);
789
+
790
  $out = '';
791
  if ( ! self::$stripe_sca_frontend_scripts_printed ) {
792
  $out .= '<script src="https://js.stripe.com/v3/"></script>';
classes/class.swpm-utils.php CHANGED
@@ -520,6 +520,14 @@ abstract class SwpmUtils {
520
  return reset( $keys ); //Return he first element from the valid values
521
  }
522
 
 
 
 
 
 
 
 
 
523
  public static function get_user_ip_address() {
524
  $user_ip = '';
525
  if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
@@ -581,4 +589,69 @@ abstract class SwpmUtils {
581
  return $output;
582
  }
583
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  }
520
  return reset( $keys ); //Return he first element from the valid values
521
  }
522
 
523
+ public static function swpm_sanitize_text( $text ) {
524
+ $text = htmlspecialchars( $text );
525
+ $text = strip_tags( $text );
526
+ $text = sanitize_text_field( $text );
527
+ $text = esc_attr( $text );
528
+ return $text;
529
+ }
530
+
531
  public static function get_user_ip_address() {
532
  $user_ip = '';
533
  if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
589
  return $output;
590
  }
591
 
592
+ public static function is_rego_form_submitted(){
593
+ if ( isset( $_POST[ 'swpm_registration_submit' ] ) ){
594
+ //Core plugin's registration form submitted
595
+ return true;
596
+ }
597
+
598
+ if ( isset( $_POST[ 'swpm-fb-submit' ] ) ){
599
+ //Form builder form submission.
600
+ return true;
601
+ }
602
+
603
+ return false;
604
+ }
605
+
606
+ public static function get_fb_rego_email_field_value(){
607
+ if ( !isset($_POST[ 'form_id' ]) ){
608
+ return '';
609
+ }
610
+ $fb_email = '';
611
+ $form_id = absint( $_POST[ 'form_id' ] );
612
+ if ( !empty($form_id) ){
613
+ //This is a form builder form. Get the email address for this custom form.
614
+ if ( !class_exists('SwpmFbForm') ){
615
+ return '';
616
+ }
617
+ $fb_form = new SwpmFbForm();
618
+ $fb_form->init_by_id( $form_id );
619
+ foreach ( $fb_form->formmeta->fields as $field ){
620
+ if ( !isset($field->key) || !is_string($field->key)){
621
+ continue;
622
+ }
623
+ if( $field->key == 'primary_email' ){
624
+ $fb_email = $fb_form->get_field_value($field);
625
+ break;
626
+ }
627
+ }
628
+ }
629
+ return $fb_email;
630
+ }
631
+
632
+ public static function csv_equal_match( $needle, $haystack_csv ) {
633
+ //converting to lowercase
634
+ if($haystack_csv && strlen($haystack_csv)>0) {
635
+ $haystack_csv = strtolower($haystack_csv);
636
+ $haystack_csv_array = explode(",",$haystack_csv);
637
+
638
+ foreach($haystack_csv_array as $value) {
639
+ if(trim($needle)==trim($value)) {
640
+ return true;
641
+ }
642
+ }
643
+ }
644
+ return false;
645
+ }
646
+
647
+
648
+ public static function csv_pattern_match( $needle, $haystack_csv ) {
649
+ if($haystack_csv && strlen($haystack_csv)>0) {
650
+ if(stripos($needle,$haystack_csv)!==false) {
651
+ return true;
652
+ }
653
+ }
654
+ return false;
655
+ }
656
+
657
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: member, members, members only, membership, memberships, register, WordPres
5
  Requires at least: 5.0
6
  Requires PHP: 5.6
7
  Tested up to: 6.0
8
- Stable tag: 4.1.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -101,6 +101,8 @@ You can create a free forum user account and ask your questions.
101
  * Option to make the users agree to your privacy policy before they can register for a member account.
102
  * Option to automatically logout the members when they close the browser.
103
  * Ability to forward the payment notification to an external URL for further processing.
 
 
104
 
105
  = Language Translations =
106
 
@@ -161,6 +163,16 @@ https://simple-membership-plugin.com/
161
 
162
  == Changelog ==
163
 
 
 
 
 
 
 
 
 
 
 
164
  = 4.1.6 =
165
  - Added a new action hook - swpm_front_end_edit_profile_form_submitted.
166
  - Added a new action hook - swpm_do_init_time_tasks_front_end.
5
  Requires at least: 5.0
6
  Requires PHP: 5.6
7
  Tested up to: 6.0
8
+ Stable tag: 4.1.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
101
  * Option to make the users agree to your privacy policy before they can register for a member account.
102
  * Option to automatically logout the members when they close the browser.
103
  * Ability to forward the payment notification to an external URL for further processing.
104
+ * Option to configure whitelisting for user email addresses to allow registration only from specific email addresses or email domains.
105
+ * Option to configure blacklisting for user email addresses to block registration from certain email addresses or email domains.
106
 
107
  = Language Translations =
108
 
163
 
164
  == Changelog ==
165
 
166
+ = 4.1.8 =
167
+ - Improved the view debug log operation to check if the file exists before trying to open the file. If the file doesn't exist, it will show a message to reset the debug file.
168
+
169
+ = 4.1.7 =
170
+ - Added a new Blacklisting & Whitelisting feature. [Usage documentation here](https://simple-membership-plugin.com/blacklisting-whitelisting-feature/)
171
+ - The member search option in the members interface will now work correctly with names containing apostrophe character.
172
+ - Added a new filter hook in the password reset function: swpm_password_reset_generated_pass
173
+ - Optimized the Stripe library loading for Stripe payment buttons so it can work with the partial protection addon.
174
+ - If after login redirection addon is not used, the redirection after login will be sent to the current page instead of the home URL.
175
+
176
  = 4.1.6 =
177
  - Added a new action hook - swpm_front_end_edit_profile_form_submitted.
178
  - Added a new action hook - swpm_do_init_time_tasks_front_end.
simple-wp-membership.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Simple WordPress Membership
4
- Version: 4.1.6
5
  Plugin URI: https://simple-membership-plugin.com/
6
  Author: smp7, wp.insider
7
  Author URI: https://simple-membership-plugin.com/
@@ -20,7 +20,7 @@ include_once( 'classes/class.simple-wp-membership.php' );
20
  include_once( 'classes/class.swpm-cronjob.php' );
21
  include_once( 'swpm-compat.php' );
22
 
23
- define( 'SIMPLE_WP_MEMBERSHIP_VER', '4.1.6' );
24
  define( 'SIMPLE_WP_MEMBERSHIP_DB_VER', '1.3' );
25
  define( 'SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url() );
26
  define( 'SIMPLE_WP_MEMBERSHIP_PATH', dirname( __FILE__ ) . '/' );
1
  <?php
2
  /*
3
  Plugin Name: Simple WordPress Membership
4
+ Version: 4.1.8
5
  Plugin URI: https://simple-membership-plugin.com/
6
  Author: smp7, wp.insider
7
  Author URI: https://simple-membership-plugin.com/
20
  include_once( 'classes/class.swpm-cronjob.php' );
21
  include_once( 'swpm-compat.php' );
22
 
23
+ define( 'SIMPLE_WP_MEMBERSHIP_VER', '4.1.8' );
24
  define( 'SIMPLE_WP_MEMBERSHIP_DB_VER', '1.3' );
25
  define( 'SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url() );
26
  define( 'SIMPLE_WP_MEMBERSHIP_PATH', dirname( __FILE__ ) . '/' );
views/admin_addon_settings.php CHANGED
@@ -1,7 +1,8 @@
1
-
2
  <p>
3
  <?php echo SwpmUtils::_("Some of the simple membership plugin's addon settings and options will be displayed here (if you have them)") ?>
4
  </p>
 
5
  <form action="" method="POST">
6
  <input type="hidden" name="tab" value="<?php echo $current_tab; ?>" />
7
  <?php do_action('swpm_addon_settings_section');
1
+ <div class="swpm-grey-box">
2
  <p>
3
  <?php echo SwpmUtils::_("Some of the simple membership plugin's addon settings and options will be displayed here (if you have them)") ?>
4
  </p>
5
+ </div>
6
  <form action="" method="POST">
7
  <input type="hidden" name="tab" value="<?php echo $current_tab; ?>" />
8
  <?php do_action('swpm_addon_settings_section');
views/admin_members_list.php CHANGED
@@ -52,7 +52,7 @@ $membership_level = filter_input(INPUT_GET, 'membership_level', FILTER_SANITIZE_
52
  <option <?php echo ($level['id'] == $membership_level) ? "selected='selected'" : ""; ?> value="<?php echo $level['id']; ?>"> <?php echo $level['alias'] ?></option>
53
  <?php endforeach; ?>
54
  </select>
55
- <input id="search_id-search-input" type="text" name="s" value="<?php echo isset($_REQUEST['s']) ? esc_attr($_REQUEST['s']) : ''; ?>" />
56
  <input id="search-submit" class="button swpm-admin-search-btn" type="submit" name="" value="<?php echo SwpmUtils::_('Search') ?>" />
57
  <input type="hidden" name="page" value="simple_wp_membership" />
58
  </p>
52
  <option <?php echo ($level['id'] == $membership_level) ? "selected='selected'" : ""; ?> value="<?php echo $level['id']; ?>"> <?php echo $level['alias'] ?></option>
53
  <?php endforeach; ?>
54
  </select>
55
+ <input id="search_id-search-input" type="text" name="s" value="<?php echo isset($_REQUEST['s']) ? esc_attr(stripslashes($_REQUEST['s'])) : ''; ?>" />
56
  <input id="search-submit" class="button swpm-admin-search-btn" type="submit" name="" value="<?php echo SwpmUtils::_('Search') ?>" />
57
  <input type="hidden" name="page" value="simple_wp_membership" />
58
  </p>
views/admin_tools_settings.php CHANGED
@@ -16,6 +16,12 @@ if(isset($_REQUEST['recreate-required-pages-submit'])){
16
  ?>
17
  <div id="poststuff">
18
  <div id="post-body">
 
 
 
 
 
 
19
 
20
  <div class="postbox">
21
  <h3 class="hndle"><label for="title"><?php echo SwpmUtils::_('Generate a Registration Completion link') ?></label></h3>
16
  ?>
17
  <div id="poststuff">
18
  <div id="post-body">
19
+
20
+ <div class="swpm-grey-box">
21
+ <p>
22
+ <?php echo SwpmUtils::_("This interface contains useful tools for various admin operations.") ?>
23
+ </p>
24
+ </div>
25
 
26
  <div class="postbox">
27
  <h3 class="hndle"><label for="title"><?php echo SwpmUtils::_('Generate a Registration Completion link') ?></label></h3>
views/payments/payment-gateway/stripe_sca_button_shortcode_view.php CHANGED
@@ -71,11 +71,20 @@ function swpm_render_stripe_sca_buy_now_button_sc_output( $button_code, $args )
71
  $output .= '<div class="swpm-button-wrapper swpm-stripe-buy-now-wrapper">';
72
  $output .= "<form id='swpm-stripe-payment-form-" . $uniqid . "' action='" . $notify_url . "' METHOD='POST'> ";
73
  $output .= "<div style='display: none !important'>";
74
- $output .= SwpmMiscUtils::output_stripe_sca_frontend_scripts_once();
 
 
 
 
 
 
 
 
 
 
75
  ob_start();
76
  ?>
77
- <script>
78
- var stripe = Stripe('<?php echo esc_js( $api_keys['public'] ); ?>');
79
  jQuery('#swpm-stripe-payment-form-<?php echo esc_js( $uniqid ); ?>').on('submit',function(e) {
80
  e.preventDefault();
81
  var btn = jQuery(this).find('button').attr('disabled', true);
@@ -86,7 +95,7 @@ function swpm_render_stripe_sca_buy_now_button_sc_output( $button_code, $args )
86
  'swpm_uniqid': '<?php echo esc_js( $uniqid ); ?>'
87
  }).done(function (response) {
88
  if (!response.error) {
89
- stripe.redirectToCheckout({sessionId: response.session_id}).then(function (result) {
90
  });
91
  } else {
92
  alert(response.error);
@@ -201,11 +210,20 @@ function swpm_render_stripe_sca_subscription_button_sc_output( $button_code, $ar
201
  $output .= '<div class="swpm-button-wrapper swpm-stripe-buy-now-wrapper">';
202
  $output .= "<form id='swpm-stripe-payment-form-" . $uniqid . "' action='" . $notify_url . "' METHOD='POST'> ";
203
  $output .= "<div style='display: none !important'>";
204
- $output .= SwpmMiscUtils::output_stripe_sca_frontend_scripts_once();
 
 
 
 
 
 
 
 
 
 
205
  ob_start();
206
  ?>
207
- <script>
208
- var stripe = Stripe('<?php echo esc_js( $api_keys['public'] ); ?>');
209
  jQuery('#swpm-stripe-payment-form-<?php echo esc_js( $uniqid ); ?>').on('submit',function(e) {
210
  e.preventDefault();
211
  var btn = jQuery(this).find('button').attr('disabled', true);
@@ -216,7 +234,7 @@ function swpm_render_stripe_sca_subscription_button_sc_output( $button_code, $ar
216
  'swpm_uniqid': '<?php echo esc_js( $uniqid ); ?>'
217
  }).done(function (response) {
218
  if (!response.error) {
219
- stripe.redirectToCheckout({sessionId: response.session_id}).then(function (result) {
220
  });
221
  } else {
222
  alert(response.error);
71
  $output .= '<div class="swpm-button-wrapper swpm-stripe-buy-now-wrapper">';
72
  $output .= "<form id='swpm-stripe-payment-form-" . $uniqid . "' action='" . $notify_url . "' METHOD='POST'> ";
73
  $output .= "<div style='display: none !important'>";
74
+
75
+ //deprecated
76
+ //$output .= SwpmMiscUtils::output_stripe_sca_frontend_scripts_once();
77
+
78
+ wp_enqueue_script("swpm.stripe");
79
+ wp_enqueue_style("swpm.stripe.style");
80
+
81
+ //initializing stripe for each button, right after loading stripe script
82
+ $stripe_js_obj="stripe_".$button_id;
83
+ wp_add_inline_script("swpm.stripe","var ".$stripe_js_obj." = Stripe('".esc_js( $api_keys['public'] )."');");
84
+
85
  ob_start();
86
  ?>
87
+ <script>
 
88
  jQuery('#swpm-stripe-payment-form-<?php echo esc_js( $uniqid ); ?>').on('submit',function(e) {
89
  e.preventDefault();
90
  var btn = jQuery(this).find('button').attr('disabled', true);
95
  'swpm_uniqid': '<?php echo esc_js( $uniqid ); ?>'
96
  }).done(function (response) {
97
  if (!response.error) {
98
+ <?php echo $stripe_js_obj;?>.redirectToCheckout({sessionId: response.session_id}).then(function (result) {
99
  });
100
  } else {
101
  alert(response.error);
210
  $output .= '<div class="swpm-button-wrapper swpm-stripe-buy-now-wrapper">';
211
  $output .= "<form id='swpm-stripe-payment-form-" . $uniqid . "' action='" . $notify_url . "' METHOD='POST'> ";
212
  $output .= "<div style='display: none !important'>";
213
+
214
+ //deprecated
215
+ //$output .= SwpmMiscUtils::output_stripe_sca_frontend_scripts_once();
216
+
217
+ wp_enqueue_script("swpm.stripe");
218
+ wp_enqueue_style("swpm.stripe.style");
219
+
220
+ //initializing stripe for each button, right after loading stripe script
221
+ $stripe_js_obj="stripe_".$button_id;
222
+ wp_add_inline_script("swpm.stripe","var ".$stripe_js_obj." = Stripe('".esc_js( $api_keys['public'] )."');");
223
+
224
  ob_start();
225
  ?>
226
+ <script>
 
227
  jQuery('#swpm-stripe-payment-form-<?php echo esc_js( $uniqid ); ?>').on('submit',function(e) {
228
  e.preventDefault();
229
  var btn = jQuery(this).find('button').attr('disabled', true);
234
  'swpm_uniqid': '<?php echo esc_js( $uniqid ); ?>'
235
  }).done(function (response) {
236
  if (!response.error) {
237
+ <?php echo $stripe_js_obj;?>.redirectToCheckout({sessionId: response.session_id}).then(function (result) {
238
  });
239
  } else {
240
  alert(response.error);