Simple Membership - Version 4.0.0

Version Description

  • Removed the "Use WordPress Timezone" settings option from the advanced settings menu. This option can conflict with some events management type plugins.
  • The plugin will now record the date values according to your WordPress timezone settings (by default).
  • The debug log file will record timestamp values in the format ['Y/m/d H:i:s']. Example Value: [2020/07/24 11:58:39]
  • Added help text to the "Admin Dashboard Access Permission" field to explain that it should not be used with the "Disable Access to WP Dashboard" option.
  • Added a note for when a user enables conflicting options in the advanced settings.
  • Completed testing on WP 5.5 version.
Download this release

Release Info

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

Code changes from version 3.9.9 to 4.0.0

classes/class.simple-wp-membership.php CHANGED
@@ -94,13 +94,13 @@ class SimpleWpMembership {
94
 
95
  function wp_password_reset_hook($user, $pass) {
96
  $swpm_user = SwpmMemberUtils::get_user_by_user_name($user->user_login);
97
-
98
  //Check if SWPM user entry exists
99
  if (empty($swpm_user)) {
100
  SwpmLog::log_auth_debug("wp_password_reset_hook() - SWPM user not found for username: '" . $user->user_login ."'. This is OK, assuming that this user was created directly in WP Users menu (not using SWPM).", true);
101
  return;
102
  }
103
-
104
  $swpm_id = $swpm_user->member_id;
105
  if (!empty($swpm_id)) {
106
  $password_hash = SwpmUtils::encrypt_password($pass);
@@ -237,9 +237,9 @@ class SimpleWpMembership {
237
  }
238
  }
239
  SwpmLog::log_auth_debug("Trying wp_signon() with username: " . $username, true);
240
-
241
  add_filter('wordfence_ls_require_captcha', '__return_false');//For Wordfence plugin's captcha compatibility
242
-
243
  $user_obj = wp_signon(array('user_login' => $username, 'user_password' => $pass, 'remember' => $rememberme), is_ssl());
244
  if ($user_obj instanceof WP_User) {
245
  wp_set_current_user($user_obj->ID, $user_obj->user_login);
@@ -308,10 +308,10 @@ class SimpleWpMembership {
308
  if ($auth->is_logged_in()) {
309
  //User is already logged-in. Nothing to do.
310
  return;
311
- }
312
  $auth->login_to_swpm_using_wp_user($user);
313
  }
314
-
315
  public function wp_authenticate_handler($username, $password) {
316
 
317
  $auth = SwpmAuth::get_instance();
@@ -397,9 +397,9 @@ class SimpleWpMembership {
397
  $fields['first_name'] = $user_info->first_name;
398
  $fields['last_name'] = $user_info->last_name;
399
  $fields['membership_level'] = $default_level;
400
- $fields['member_since'] = date('Y-m-d');
401
  $fields['account_state'] = $default_ac_status;
402
- $fields['subscription_starts'] = date('Y-m-d');
403
  SwpmMemberUtils::create_swpm_member_entry_from_array_data($fields);
404
  }
405
 
@@ -463,7 +463,7 @@ class SimpleWpMembership {
463
  }
464
 
465
  /*
466
- * This function is hooked to WordPress's admin_notices action hook
467
  * It is used to show any plugin specific notices/warnings in the admin interface
468
  */
469
 
@@ -686,7 +686,7 @@ class SimpleWpMembership {
686
  ),
687
  'SWPMUserName' => array(
688
  'alertText' => '* ' . SwpmUtils::_('Invalid Username').'<br>'.SwpmUtils::_('Usernames can only contain: letters, numbers and .-_*@'),
689
- ),
690
  'minSize' => array(
691
  'alertText' => '* ' . SwpmUtils::_('Minimum '),
692
  'alertText2' => SwpmUtils::_(' characters required'),
94
 
95
  function wp_password_reset_hook($user, $pass) {
96
  $swpm_user = SwpmMemberUtils::get_user_by_user_name($user->user_login);
97
+
98
  //Check if SWPM user entry exists
99
  if (empty($swpm_user)) {
100
  SwpmLog::log_auth_debug("wp_password_reset_hook() - SWPM user not found for username: '" . $user->user_login ."'. This is OK, assuming that this user was created directly in WP Users menu (not using SWPM).", true);
101
  return;
102
  }
103
+
104
  $swpm_id = $swpm_user->member_id;
105
  if (!empty($swpm_id)) {
106
  $password_hash = SwpmUtils::encrypt_password($pass);
237
  }
238
  }
239
  SwpmLog::log_auth_debug("Trying wp_signon() with username: " . $username, true);
240
+
241
  add_filter('wordfence_ls_require_captcha', '__return_false');//For Wordfence plugin's captcha compatibility
242
+
243
  $user_obj = wp_signon(array('user_login' => $username, 'user_password' => $pass, 'remember' => $rememberme), is_ssl());
244
  if ($user_obj instanceof WP_User) {
245
  wp_set_current_user($user_obj->ID, $user_obj->user_login);
308
  if ($auth->is_logged_in()) {
309
  //User is already logged-in. Nothing to do.
310
  return;
311
+ }
312
  $auth->login_to_swpm_using_wp_user($user);
313
  }
314
+
315
  public function wp_authenticate_handler($username, $password) {
316
 
317
  $auth = SwpmAuth::get_instance();
397
  $fields['first_name'] = $user_info->first_name;
398
  $fields['last_name'] = $user_info->last_name;
399
  $fields['membership_level'] = $default_level;
400
+ $fields['member_since'] = SwpmUtils::get_current_date_in_wp_zone();
401
  $fields['account_state'] = $default_ac_status;
402
+ $fields['subscription_starts'] = SwpmUtils::get_current_date_in_wp_zone();
403
  SwpmMemberUtils::create_swpm_member_entry_from_array_data($fields);
404
  }
405
 
463
  }
464
 
465
  /*
466
+ * This function is hooked to WordPress's admin_notices action hook
467
  * It is used to show any plugin specific notices/warnings in the admin interface
468
  */
469
 
686
  ),
687
  'SWPMUserName' => array(
688
  'alertText' => '* ' . SwpmUtils::_('Invalid Username').'<br>'.SwpmUtils::_('Usernames can only contain: letters, numbers and .-_*@'),
689
+ ),
690
  'minSize' => array(
691
  'alertText' => '* ' . SwpmUtils::_('Minimum '),
692
  'alertText2' => SwpmUtils::_(' characters required'),
classes/class.swpm-front-registration.php CHANGED
@@ -214,8 +214,8 @@ class SwpmFrontRegistration extends SwpmRegistration {
214
  $free_level = SwpmUtils::get_free_level();
215
  $account_status = SwpmSettings::get_instance()->get_value( 'default-account-status', 'active' );
216
  $member_info['last_accessed_from_ip'] = SwpmUtils::get_user_ip_address();
217
- $member_info['member_since'] = date( 'Y-m-d' );
218
- $member_info['subscription_starts'] = date( 'Y-m-d' );
219
  $member_info['account_state'] = $account_status;
220
  if ( $this->email_activation ) {
221
  $member_info['account_state'] = 'activation_required';
214
  $free_level = SwpmUtils::get_free_level();
215
  $account_status = SwpmSettings::get_instance()->get_value( 'default-account-status', 'active' );
216
  $member_info['last_accessed_from_ip'] = SwpmUtils::get_user_ip_address();
217
+ $member_info['member_since'] = SwpmUtils::get_current_date_in_wp_zone(); //date( 'Y-m-d' );
218
+ $member_info['subscription_starts'] = SwpmUtils::get_current_date_in_wp_zone(); //date( 'Y-m-d' );
219
  $member_info['account_state'] = $account_status;
220
  if ( $this->email_activation ) {
221
  $member_info['account_state'] = 'activation_required';
classes/class.swpm-log.php CHANGED
@@ -42,7 +42,7 @@ class SwpmLog {
42
  public static function writeall($path = ''){
43
  if (empty($path)) {$path = SIMPLE_WP_MEMBERSHIP_PATH . 'log.txt';}
44
  $fp = fopen($path, 'a');
45
- $date = date("Y-m-d H:i:s");
46
  fwrite($fp, strtoupper($date) . ":\n");
47
  fwrite($fp, str_repeat('-=', (strlen($date)+1.0)/2.0) . "\n");
48
  foreach (self::$intance as $context=>$intance){
@@ -64,7 +64,8 @@ class SwpmLog {
64
  $debug_log_file_name = SIMPLE_WP_MEMBERSHIP_PATH . 'log.txt';
65
 
66
  // Timestamp
67
- $text = '[' . date('m/d/Y g:i A') . '] - ' . (($success) ? 'SUCCESS: ' : 'FAILURE: ') . $message . "\n";
 
68
  if ($end) {
69
  $text .= "\n------------------------------------------------------------------\n\n";
70
  }
@@ -73,7 +74,7 @@ class SwpmLog {
73
  fwrite($fp, $text);
74
  fclose($fp); // close file
75
  }
76
-
77
  public static function log_array_data_to_debug($array_to_write, $success, $end = false) {
78
  $settings = SwpmSettings::get_instance();
79
  $debug_enabled = $settings->get_value('enable-debug');
@@ -85,13 +86,14 @@ class SwpmLog {
85
  $debug_log_file_name = SIMPLE_WP_MEMBERSHIP_PATH . 'log.txt';
86
 
87
  // Timestamp
88
- $text = '[' . date('m/d/Y g:i A') . '] - ' . (($success) ? 'SUCCESS: ' : 'FAILURE: ') . "\n";
 
89
  ob_start();
90
  print_r($array_to_write);
91
  $var = ob_get_contents();
92
  ob_end_clean();
93
  $text .= $var;
94
-
95
  if ($end) {
96
  $text .= "\n------------------------------------------------------------------\n\n";
97
  }
@@ -100,7 +102,7 @@ class SwpmLog {
100
  fwrite($fp, $text);
101
  fclose($fp); // close file
102
  }
103
-
104
  public static function log_auth_debug($message, $success, $end = false) {
105
  $settings = SwpmSettings::get_instance();
106
  $debug_enabled = $settings->get_value('enable-debug');
@@ -112,7 +114,8 @@ class SwpmLog {
112
  $debug_log_file_name = SIMPLE_WP_MEMBERSHIP_PATH . 'log-auth.txt';
113
 
114
  // Timestamp
115
- $text = '[' . date('m/d/Y g:i A') . '] - ' . (($success) ? 'SUCCESS: ' : 'FAILURE: ') . $message . "\n";
 
116
  if ($end) {
117
  $text .= "\n------------------------------------------------------------------\n\n";
118
  }
@@ -120,8 +123,8 @@ class SwpmLog {
120
  $fp = fopen($debug_log_file_name, 'a');
121
  fwrite($fp, $text);
122
  fclose($fp); // close file
123
- }
124
-
125
  public static function reset_swmp_log_files() {
126
  $log_reset = true;
127
  $logfile_list = array(
@@ -134,7 +137,8 @@ class SwpmLog {
134
  continue;
135
  }
136
 
137
- $text = '[' . date('m/d/Y g:i A') . '] - SUCCESS: Log file reset';
 
138
  $text .= "\n------------------------------------------------------------------\n\n";
139
  $fp = fopen($logfile, 'w');
140
  if ($fp != FALSE) {
@@ -145,6 +149,6 @@ class SwpmLog {
145
  }
146
  }
147
  return $log_reset;
148
- }
149
 
150
  }
42
  public static function writeall($path = ''){
43
  if (empty($path)) {$path = SIMPLE_WP_MEMBERSHIP_PATH . 'log.txt';}
44
  $fp = fopen($path, 'a');
45
+ $date = current_time('mysql');
46
  fwrite($fp, strtoupper($date) . ":\n");
47
  fwrite($fp, str_repeat('-=', (strlen($date)+1.0)/2.0) . "\n");
48
  foreach (self::$intance as $context=>$intance){
64
  $debug_log_file_name = SIMPLE_WP_MEMBERSHIP_PATH . 'log.txt';
65
 
66
  // Timestamp
67
+ $log_timestamp = SwpmUtils::get_current_timestamp_for_debug_log();
68
+ $text = '[' . $log_timestamp . '] - ' . (($success) ? 'SUCCESS: ' : 'FAILURE: ') . $message . "\n";
69
  if ($end) {
70
  $text .= "\n------------------------------------------------------------------\n\n";
71
  }
74
  fwrite($fp, $text);
75
  fclose($fp); // close file
76
  }
77
+
78
  public static function log_array_data_to_debug($array_to_write, $success, $end = false) {
79
  $settings = SwpmSettings::get_instance();
80
  $debug_enabled = $settings->get_value('enable-debug');
86
  $debug_log_file_name = SIMPLE_WP_MEMBERSHIP_PATH . 'log.txt';
87
 
88
  // Timestamp
89
+ $log_timestamp = SwpmUtils::get_current_timestamp_for_debug_log();
90
+ $text = '[' . $log_timestamp . '] - ' . (($success) ? 'SUCCESS: ' : 'FAILURE: ') . "\n";
91
  ob_start();
92
  print_r($array_to_write);
93
  $var = ob_get_contents();
94
  ob_end_clean();
95
  $text .= $var;
96
+
97
  if ($end) {
98
  $text .= "\n------------------------------------------------------------------\n\n";
99
  }
102
  fwrite($fp, $text);
103
  fclose($fp); // close file
104
  }
105
+
106
  public static function log_auth_debug($message, $success, $end = false) {
107
  $settings = SwpmSettings::get_instance();
108
  $debug_enabled = $settings->get_value('enable-debug');
114
  $debug_log_file_name = SIMPLE_WP_MEMBERSHIP_PATH . 'log-auth.txt';
115
 
116
  // Timestamp
117
+ $log_timestamp = SwpmUtils::get_current_timestamp_for_debug_log();
118
+ $text = '[' . $log_timestamp . '] - ' . (($success) ? 'SUCCESS: ' : 'FAILURE: ') . $message . "\n";
119
  if ($end) {
120
  $text .= "\n------------------------------------------------------------------\n\n";
121
  }
123
  $fp = fopen($debug_log_file_name, 'a');
124
  fwrite($fp, $text);
125
  fclose($fp); // close file
126
+ }
127
+
128
  public static function reset_swmp_log_files() {
129
  $log_reset = true;
130
  $logfile_list = array(
137
  continue;
138
  }
139
 
140
+ $log_timestamp = SwpmUtils::get_current_timestamp_for_debug_log();
141
+ $text = '[' . $log_timestamp . '] - SUCCESS: Log file reset';
142
  $text .= "\n------------------------------------------------------------------\n\n";
143
  $fp = fopen($logfile, 'w');
144
  if ($fp != FALSE) {
149
  }
150
  }
151
  return $log_reset;
152
+ }
153
 
154
  }
classes/class.swpm-members.php CHANGED
@@ -240,8 +240,8 @@ class SwpmMembers extends WP_List_Table {
240
  }
241
  global $wpdb;
242
  $member = SwpmTransfer::$default_fields;
243
- $member['member_since'] = date( 'Y-m-d' );
244
- $member['subscription_starts'] = date( 'Y-m-d' );
245
  if ( isset( $_POST['createswpmuser'] ) ) {
246
  $member = array_map( 'sanitize_text_field', $_POST );
247
  }
240
  }
241
  global $wpdb;
242
  $member = SwpmTransfer::$default_fields;
243
+ $member['member_since'] = SwpmUtils::get_current_date_in_wp_zone();//date( 'Y-m-d' );
244
+ $member['subscription_starts'] = SwpmUtils::get_current_date_in_wp_zone();//date( 'Y-m-d' );
245
  if ( isset( $_POST['createswpmuser'] ) ) {
246
  $member = array_map( 'sanitize_text_field', $_POST );
247
  }
classes/class.swpm-settings.php CHANGED
@@ -676,18 +676,6 @@ class SwpmSettings {
676
  )
677
  );
678
 
679
- add_settings_field(
680
- 'use-wordpress-timezone',
681
- SwpmUtils::_( 'Use WordPress Timezone' ),
682
- array( &$this, 'checkbox_callback' ),
683
- 'simple_wp_membership_settings',
684
- 'advanced-settings',
685
- array(
686
- 'item' => 'use-wordpress-timezone',
687
- 'message' => SwpmUtils::_( 'Use this option if you want to use the timezone value specified in your WordPress General Settings interface.' ),
688
- )
689
- );
690
-
691
  add_settings_field(
692
  'delete-pending-account',
693
  SwpmUtils::_( 'Auto Delete Pending Account' ),
@@ -721,7 +709,7 @@ class SwpmSettings {
721
  'edit_posts' => 'Contributor',
722
  ),
723
  'default' => 'manage_options',
724
- 'message' => SwpmUtils::_( 'SWPM admin dashboard is accessible to admin users only (just like any other plugin). You can allow users with other WP user role to access the SWPM admin dashboard by selecting a value here.' ),
725
  )
726
  );
727
 
@@ -1029,6 +1017,25 @@ class SwpmSettings {
1029
  if ( isset( $_REQUEST['settings-updated'] ) ) {
1030
  //This status message need to be in the callback function to prevent header sent warning
1031
  echo '<div id="message" class="updated fade"><p>' . SwpmUtils::_( 'Settings updated!' ) . '</p></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1032
  }
1033
 
1034
  SwpmUtils::e( 'This page allows you to configure some advanced features of the plugin.' );
@@ -1131,7 +1138,6 @@ class SwpmSettings {
1131
  $output['enable-expired-account-login'] = isset( $input['enable-expired-account-login'] ) ? esc_attr( $input['enable-expired-account-login'] ) : '';
1132
  $output['logout-member-on-browser-close'] = isset( $input['logout-member-on-browser-close'] ) ? esc_attr( $input['logout-member-on-browser-close'] ) : '';
1133
  $output['allow-account-deletion'] = isset( $input['allow-account-deletion'] ) ? esc_attr( $input['allow-account-deletion'] ) : '';
1134
- $output['use-wordpress-timezone'] = isset( $input['use-wordpress-timezone'] ) ? esc_attr( $input['use-wordpress-timezone'] ) : '';
1135
  $output['delete-pending-account'] = isset( $input['delete-pending-account'] ) ? esc_attr( $input['delete-pending-account'] ) : 0;
1136
  $output['admin-dashboard-access-permission'] = isset( $input['admin-dashboard-access-permission'] ) ? esc_attr( $input['admin-dashboard-access-permission'] ) : '';
1137
  $output['renewal-page-url'] = esc_url( $input['renewal-page-url'] );
676
  )
677
  );
678
 
 
 
 
 
 
 
 
 
 
 
 
 
679
  add_settings_field(
680
  'delete-pending-account',
681
  SwpmUtils::_( 'Auto Delete Pending Account' ),
709
  'edit_posts' => 'Contributor',
710
  ),
711
  'default' => 'manage_options',
712
+ 'message' => SwpmUtils::_( 'SWPM admin dashboard is accessible to admin users only (just like any other plugin). You can allow users with other WP user role to access the SWPM admin dashboard by selecting a value here. Note that this option cannot work if you enabled the "Disable Access to WP Dashboard" option in General Settings.' ),
713
  )
714
  );
715
 
1017
  if ( isset( $_REQUEST['settings-updated'] ) ) {
1018
  //This status message need to be in the callback function to prevent header sent warning
1019
  echo '<div id="message" class="updated fade"><p>' . SwpmUtils::_( 'Settings updated!' ) . '</p></div>';
1020
+
1021
+ /* Check if any conflicting setting options have been enabled together. */
1022
+ $disable_wp_dashboard_for_non_admins = $this->get_value('disable-access-to-wp-dashboard');
1023
+ if ($disable_wp_dashboard_for_non_admins) {
1024
+ //The disable wp dashboard option is enabled.
1025
+ //Check to make sure the "Admin Dashboard Access Permission" option is not being used for other roles.
1026
+ $admin_dashboard_permission = $this->get_value( 'admin-dashboard-access-permission' );
1027
+ if ( empty( $admin_dashboard_permission ) || $admin_dashboard_permission == 'manage_options' ) {
1028
+ //This is fine.
1029
+ } else {
1030
+ //Conflicting options enabled.
1031
+ //Show warning and reset the option value to default.
1032
+ $this->set_value('admin-dashboard-access-permission', 'manage_options');
1033
+ $this->save();
1034
+ echo '<div id="message" class="error"><p>' . SwpmUtils::_( 'Note: You cannot enable both the "Disable Access to WP Dashboard" and "Admin Dashboard Access Permission" options at the same time. Only use one of those options.' ) . '</p></div>';
1035
+ }
1036
+ }
1037
+ /* End of conflicting options check */
1038
+
1039
  }
1040
 
1041
  SwpmUtils::e( 'This page allows you to configure some advanced features of the plugin.' );
1138
  $output['enable-expired-account-login'] = isset( $input['enable-expired-account-login'] ) ? esc_attr( $input['enable-expired-account-login'] ) : '';
1139
  $output['logout-member-on-browser-close'] = isset( $input['logout-member-on-browser-close'] ) ? esc_attr( $input['logout-member-on-browser-close'] ) : '';
1140
  $output['allow-account-deletion'] = isset( $input['allow-account-deletion'] ) ? esc_attr( $input['allow-account-deletion'] ) : '';
 
1141
  $output['delete-pending-account'] = isset( $input['delete-pending-account'] ) ? esc_attr( $input['delete-pending-account'] ) : 0;
1142
  $output['admin-dashboard-access-permission'] = isset( $input['admin-dashboard-access-permission'] ) ? esc_attr( $input['admin-dashboard-access-permission'] ) : '';
1143
  $output['renewal-page-url'] = esc_url( $input['renewal-page-url'] );
classes/class.swpm-transactions.php CHANGED
@@ -9,7 +9,7 @@ class SwpmTransactions {
9
  static function save_txn_record( $ipn_data, $items = array() ) {
10
  global $wpdb;
11
 
12
- $current_date = date( 'Y-m-d' );
13
  $custom_var = self::parse_custom_var( $ipn_data['custom'] );
14
 
15
  $txn_data = array();
9
  static function save_txn_record( $ipn_data, $items = array() ) {
10
  global $wpdb;
11
 
12
+ $current_date = SwpmUtils::get_current_date_in_wp_zone();//date( 'Y-m-d' );
13
  $custom_var = self::parse_custom_var( $ipn_data['custom'] );
14
 
15
  $txn_data = array();
classes/class.swpm-utils-member.php CHANGED
@@ -179,7 +179,7 @@ class SwpmMemberUtils {
179
  $membership_level = $args['membership_level'];
180
  $old_membership_level = $args['old_membership_level'];
181
 
182
- $subscription_starts = ( date( 'Y-m-d' ) );
183
  if ( $membership_level == $old_membership_level ) {
184
  //Payment for the same membership level (renewal).
185
 
179
  $membership_level = $args['membership_level'];
180
  $old_membership_level = $args['old_membership_level'];
181
 
182
+ $subscription_starts = SwpmUtils::get_current_date_in_wp_zone();//( date( 'Y-m-d' ) );
183
  if ( $membership_level == $old_membership_level ) {
184
  //Payment for the same membership level (renewal).
185
 
classes/class.swpm-utils.php CHANGED
@@ -20,15 +20,6 @@ abstract class SwpmUtils {
20
  } else {
21
  define( 'SWPM_MANAGEMENT_PERMISSION', $admin_dashboard_permission );
22
  }
23
-
24
- //Set timezone preference (if enabled in settings)
25
- $use_wp_timezone = SwpmSettings::get_instance()->get_value( 'use-wordpress-timezone' );
26
- if ( ! empty( $use_wp_timezone ) ) {//Set the wp timezone
27
- $wp_timezone_string = get_option( 'timezone_string' );
28
- if ( ! empty( $wp_timezone_string ) ) {
29
- date_default_timezone_set( $wp_timezone_string );
30
- }
31
- }
32
  }
33
 
34
  public static function subscription_type_dropdown( $selected ) {
@@ -333,6 +324,26 @@ abstract class SwpmUtils {
333
  }
334
  }
335
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  /*
337
  * Formats the given date value according to the WP date format settings. This function is useful for displaying a human readable date value to the user.
338
  */
20
  } else {
21
  define( 'SWPM_MANAGEMENT_PERMISSION', $admin_dashboard_permission );
22
  }
 
 
 
 
 
 
 
 
 
23
  }
24
 
25
  public static function subscription_type_dropdown( $selected ) {
324
  }
325
  }
326
 
327
+ /*
328
+ * Returns the current date timestamp value suitable for debug log file.
329
+ */
330
+ public static function get_current_timestamp_for_debug_log(){
331
+ $current_wp_time = current_time('mysql');
332
+ $dt = new DateTime($current_wp_time);
333
+ $current_date = $dt->format('Y/m/d H:i:s');
334
+ return $current_date;
335
+ }
336
+
337
+ /*
338
+ * Returns the current date value in (Y-m-d) format in the timzeone set for this WordPress install.
339
+ */
340
+ public static function get_current_date_in_wp_zone(){
341
+ $current_wp_time = current_time('mysql');
342
+ $dt = new DateTime($current_wp_time);
343
+ $current_date = $dt->format('Y-m-d');
344
+ return $current_date;
345
+ }
346
+
347
  /*
348
  * Formats the given date value according to the WP date format settings. This function is useful for displaying a human readable date value to the user.
349
  */
ipn/swpm_handle_subsc_ipn.php CHANGED
@@ -131,7 +131,7 @@ function swpm_handle_subsc_signup_stand_alone( $ipn_data, $subsc_ref, $unique_re
131
  $data['address_state'] = $ipn_data['address_state'];
132
  $data['address_zipcode'] = isset( $ipn_data['address_zip'] ) ? $ipn_data['address_zip'] : '';
133
  $data['country'] = isset( $ipn_data['address_country'] ) ? $ipn_data['address_country'] : '';
134
- $data['member_since'] = $data['subscription_starts'] = $data['last_accessed'] = date( 'Y-m-d' );
135
  $data['account_state'] = $default_account_status;
136
  $reg_code = uniqid();
137
  $md5_code = md5( $reg_code );
@@ -302,7 +302,7 @@ function swpm_update_member_subscription_start_date_if_applicable( $ipn_data ) {
302
  $ipn_data['member_id'] = $swpm_id;
303
  do_action( 'swpm_recurring_payment_received', $ipn_data ); // Hook for recurring payment received.
304
 
305
- $subscription_starts = ( date( 'Y-m-d' ) );
306
 
307
  $wpdb->query(
308
  $wpdb->prepare(
@@ -357,7 +357,8 @@ function swpm_debug_log_subsc( $message, $success, $end = false ) {
357
  $debug_log_file_name = SIMPLE_WP_MEMBERSHIP_PATH . 'log.txt';
358
 
359
  // Timestamp.
360
- $text = '[' . date( 'm/d/Y g:i A' ) . '] - ' . ( ( $success ) ? 'SUCCESS: ' : 'FAILURE: ' ) . $message . "\n";
 
361
  if ( $end ) {
362
  $text .= "\n------------------------------------------------------------------\n\n";
363
  }
131
  $data['address_state'] = $ipn_data['address_state'];
132
  $data['address_zipcode'] = isset( $ipn_data['address_zip'] ) ? $ipn_data['address_zip'] : '';
133
  $data['country'] = isset( $ipn_data['address_country'] ) ? $ipn_data['address_country'] : '';
134
+ $data['member_since'] = $data['subscription_starts'] = $data['last_accessed'] = SwpmUtils::get_current_date_in_wp_zone();
135
  $data['account_state'] = $default_account_status;
136
  $reg_code = uniqid();
137
  $md5_code = md5( $reg_code );
302
  $ipn_data['member_id'] = $swpm_id;
303
  do_action( 'swpm_recurring_payment_received', $ipn_data ); // Hook for recurring payment received.
304
 
305
+ $subscription_starts = SwpmUtils::get_current_date_in_wp_zone();
306
 
307
  $wpdb->query(
308
  $wpdb->prepare(
357
  $debug_log_file_name = SIMPLE_WP_MEMBERSHIP_PATH . 'log.txt';
358
 
359
  // Timestamp.
360
+ $log_timestamp = SwpmUtils::get_current_timestamp_for_debug_log();
361
+ $text = '[' . $log_timestamp . '] - ' . ( ( $success ) ? 'SUCCESS: ' : 'FAILURE: ' ) . $message . "\n";
362
  if ( $end ) {
363
  $text .= "\n------------------------------------------------------------------\n\n";
364
  }
languages/simple-membership.pot CHANGED
@@ -1294,7 +1294,7 @@ msgstr ""
1294
  msgid ""
1295
  "SWPM admin dashboard is accessible to admin users only (just like any other "
1296
  "plugin). You can allow users with other WP user role to access the SWPM "
1297
- "admin dashboard by selecting a value here."
1298
  msgstr ""
1299
 
1300
  #: classes/class.swpm-settings.php:226
1294
  msgid ""
1295
  "SWPM admin dashboard is accessible to admin users only (just like any other "
1296
  "plugin). You can allow users with other WP user role to access the SWPM "
1297
+ "admin dashboard by selecting a value here. Note that this option cannot work if you enabled the \"Disable Access to WP Dashboard\" option in General Settings."
1298
  msgstr ""
1299
 
1300
  #: classes/class.swpm-settings.php:226
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: smp7, wp.insider
3
  Donate link: https://simple-membership-plugin.com/
4
  Tags: member, members, members only, membership, memberships, register, WordPress membership plugin, content, content protection, paypal, restrict, restrict access, Restrict content, admin, access control, subscription, teaser, protection, profile, login, login page, bbpress, stripe, braintree
5
  Requires at least: 4.0
6
- Tested up to: 5.4
7
- Stable tag: 3.9.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -158,6 +158,14 @@ https://simple-membership-plugin.com/
158
 
159
  == Changelog ==
160
 
 
 
 
 
 
 
 
 
161
  = 3.9.9 =
162
  - Added an enhancement to accept empty address value and force updating (when admin updates the address of a member profile from admin interface).
163
 
3
  Donate link: https://simple-membership-plugin.com/
4
  Tags: member, members, members only, membership, memberships, register, WordPress membership plugin, content, content protection, paypal, restrict, restrict access, Restrict content, admin, access control, subscription, teaser, protection, profile, login, login page, bbpress, stripe, braintree
5
  Requires at least: 4.0
6
+ Tested up to: 5.5
7
+ Stable tag: 4.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
158
 
159
  == Changelog ==
160
 
161
+ = 4.0.0 =
162
+ - Removed the "Use WordPress Timezone" settings option from the advanced settings menu. This option can conflict with some events management type plugins.
163
+ - The plugin will now record the date values according to your WordPress timezone settings (by default).
164
+ - The debug log file will record timestamp values in the format ['Y/m/d H:i:s']. Example Value: [2020/07/24 11:58:39]
165
+ - Added help text to the "Admin Dashboard Access Permission" field to explain that it should not be used with the "Disable Access to WP Dashboard" option.
166
+ - Added a note for when a user enables conflicting options in the advanced settings.
167
+ - Completed testing on WP 5.5 version.
168
+
169
  = 3.9.9 =
170
  - Added an enhancement to accept empty address value and force updating (when admin updates the address of a member profile from admin interface).
171
 
simple-wp-membership.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Simple WordPress Membership
4
- Version: 3.9.9
5
  Plugin URI: https://simple-membership-plugin.com/
6
  Author: smp7, wp.insider
7
  Author URI: https://simple-membership-plugin.com/
@@ -19,7 +19,7 @@ include_once('classes/class.simple-wp-membership.php');
19
  include_once('classes/class.swpm-cronjob.php');
20
  include_once('swpm-compat.php');
21
 
22
- define('SIMPLE_WP_MEMBERSHIP_VER', '3.9.9');
23
  define('SIMPLE_WP_MEMBERSHIP_DB_VER', '1.3');
24
  define('SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url());
25
  define('SIMPLE_WP_MEMBERSHIP_PATH', dirname(__FILE__) . '/');
1
  <?php
2
  /*
3
  Plugin Name: Simple WordPress Membership
4
+ Version: 4.0.0
5
  Plugin URI: https://simple-membership-plugin.com/
6
  Author: smp7, wp.insider
7
  Author URI: https://simple-membership-plugin.com/
19
  include_once('classes/class.swpm-cronjob.php');
20
  include_once('swpm-compat.php');
21
 
22
+ define('SIMPLE_WP_MEMBERSHIP_VER', '4.0.0');
23
  define('SIMPLE_WP_MEMBERSHIP_DB_VER', '1.3');
24
  define('SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url());
25
  define('SIMPLE_WP_MEMBERSHIP_PATH', dirname(__FILE__) . '/');
views/payments/admin_add_edit_transaction_manually.php CHANGED
@@ -15,7 +15,7 @@ function swpm_handle_add_new_txn_manually(){
15
  //Check nonce first
16
  check_admin_referer( 'swpm_admin_add_new_txn_form_action', 'swpm_admin_add_new_txn_form_field' );
17
 
18
- $current_date = date( 'Y-m-d' );
19
 
20
  $txn_data = array();
21
  $txn_data['email'] = sanitize_text_field( $_POST['email_address'] );
15
  //Check nonce first
16
  check_admin_referer( 'swpm_admin_add_new_txn_form_action', 'swpm_admin_add_new_txn_form_field' );
17
 
18
+ $current_date = SwpmUtils::get_current_date_in_wp_zone();
19
 
20
  $txn_data = array();
21
  $txn_data['email'] = sanitize_text_field( $_POST['email_address'] );