Simple Membership - Version 3.2.2

Version Description

  • New feature to only allow the members of the site to be able to post a comment.
  • Moved the "Allow Account Deletion" option to the Advanced Settings tab of the plugin.
  • Moved the "Auto Delete Pending Account" option to the Advanced Settings tab of the plugin.
  • WordPress 4.5 compatibility.
Download this release

Release Info

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

Code changes from version 3.2.1 to 3.2.2

classes/class.simple-wp-membership.php CHANGED
@@ -5,6 +5,7 @@ include_once('class.swpm-utils.php');
5
  include_once('class.swpm-utils-member.php');
6
  include_once('class.swpm-utils-template.php');
7
  include_once('class.swpm-init-time-tasks.php');
 
8
  include_once('class.swpm-settings.php');
9
  include_once('class.swpm-protection.php');
10
  include_once('class.swpm-permission.php');
@@ -39,6 +40,7 @@ class SimpleWpMembership {
39
  add_filter('widget_text', 'do_shortcode');
40
  add_filter('show_admin_bar', array(&$this, 'hide_adminbar'));
41
  add_filter('comment_text', array(&$this, 'filter_comment'));
 
42
  add_filter('wp_get_attachment_url', array(&$this, 'filter_attachment_url'), 10, 2);
43
  add_filter('wp_get_attachment_metadata', array(&$this, 'filter_attachment'), 10, 2);
44
  add_filter('attachment_fields_to_save', array(&$this, 'save_attachment_extra'), 10, 2);
@@ -53,6 +55,7 @@ class SimpleWpMembership {
53
 
54
  new SwpmShortcodesHandler(); //Tackle the shortcode definitions and implementation.
55
 
 
56
  add_action('save_post', array(&$this, 'save_postdata'));
57
  add_action('admin_notices', array(&$this, 'notices'));
58
  add_action('wp_enqueue_scripts', array(&$this, 'front_library'));
@@ -62,7 +65,7 @@ class SimpleWpMembership {
62
  add_action('wp_logout', array(&$this, 'wp_logout'));
63
  add_action('wp_authenticate', array(&$this, 'wp_login'), 1, 2);
64
  add_action('swpm_logout', array(&$this, 'swpm_logout'));
65
-
66
  //AJAX hooks
67
  add_action('wp_ajax_swpm_validate_email', 'SwpmAjax::validate_email_ajax');
68
  add_action('wp_ajax_nopriv_swpm_validate_email', 'SwpmAjax::validate_email_ajax');
@@ -74,6 +77,16 @@ class SimpleWpMembership {
74
  add_action('plugins_loaded', array(&$this, "plugins_loaded"));
75
  add_action('password_reset', array(&$this, 'wp_password_reset_hook'), 10, 2);
76
  }
 
 
 
 
 
 
 
 
 
 
77
 
78
  function wp_password_reset_hook($user, $pass) {
79
  $swpm_user = SwpmMemberUtils::get_user_by_user_name($user->user_login);
5
  include_once('class.swpm-utils-member.php');
6
  include_once('class.swpm-utils-template.php');
7
  include_once('class.swpm-init-time-tasks.php');
8
+ include_once('class.swpm-comment-form-related.php');
9
  include_once('class.swpm-settings.php');
10
  include_once('class.swpm-protection.php');
11
  include_once('class.swpm-permission.php');
40
  add_filter('widget_text', 'do_shortcode');
41
  add_filter('show_admin_bar', array(&$this, 'hide_adminbar'));
42
  add_filter('comment_text', array(&$this, 'filter_comment'));
43
+ add_filter('comment_form_defaults', array('SwpmCommentFormRelated', 'customize_comment_fields'));
44
  add_filter('wp_get_attachment_url', array(&$this, 'filter_attachment_url'), 10, 2);
45
  add_filter('wp_get_attachment_metadata', array(&$this, 'filter_attachment'), 10, 2);
46
  add_filter('attachment_fields_to_save', array(&$this, 'save_attachment_extra'), 10, 2);
55
 
56
  new SwpmShortcodesHandler(); //Tackle the shortcode definitions and implementation.
57
 
58
+ add_action('wp_head', array(&$this,'wp_head_callback'));
59
  add_action('save_post', array(&$this, 'save_postdata'));
60
  add_action('admin_notices', array(&$this, 'notices'));
61
  add_action('wp_enqueue_scripts', array(&$this, 'front_library'));
65
  add_action('wp_logout', array(&$this, 'wp_logout'));
66
  add_action('wp_authenticate', array(&$this, 'wp_login'), 1, 2);
67
  add_action('swpm_logout', array(&$this, 'swpm_logout'));
68
+
69
  //AJAX hooks
70
  add_action('wp_ajax_swpm_validate_email', 'SwpmAjax::validate_email_ajax');
71
  add_action('wp_ajax_nopriv_swpm_validate_email', 'SwpmAjax::validate_email_ajax');
77
  add_action('plugins_loaded', array(&$this, "plugins_loaded"));
78
  add_action('password_reset', array(&$this, 'wp_password_reset_hook'), 10, 2);
79
  }
80
+
81
+ public function wp_head_callback(){
82
+ //This function is triggered by the wp_head action hook
83
+
84
+ //Check if members only commenting is allowed then customize the form accordingly
85
+ SwpmCommentFormRelated::customize_comment_form();
86
+
87
+ //Other wp_head related tasks go here.
88
+
89
+ }
90
 
91
  function wp_password_reset_hook($user, $pass) {
92
  $swpm_user = SwpmMemberUtils::get_user_by_user_name($user->user_login);
classes/class.swpm-comment-form-related.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SwpmCommentFormRelated {
4
+
5
+ public static function customize_comment_form() {
6
+ $allow_comments = SwpmSettings::get_instance()->get_value('members-login-to-comment');
7
+ if (empty($allow_comments)){
8
+ return;
9
+ }
10
+ if (SwpmAuth::get_instance()->is_logged_in()){
11
+ return;
12
+ }
13
+
14
+ //Apply a filter to the message so it can be customized using the custom message plugin
15
+ $comment_form_msg = apply_filters('swpm_login_to_comment_msg', SwpmUtils::_("Please login to comment."));
16
+ $comment_form_msg = '<div class="swpm-login-to-comment-msg">' . $comment_form_msg . '</div>';
17
+ ?>
18
+ <script type="text/javascript">
19
+ jQuery(document).ready(function($) {
20
+ $('#respond').html('<?php echo $comment_form_msg; ?>');
21
+ });
22
+ </script>
23
+ <?php
24
+ }
25
+
26
+ public static function customize_comment_fields($fields){
27
+
28
+ //Check if login to comment feature is enabled.
29
+ $allow_comments = SwpmSettings::get_instance()->get_value('members-login-to-comment');
30
+ if (empty($allow_comments)){//Feature is disabled
31
+ return $fields;
32
+ }
33
+
34
+ if (SwpmAuth::get_instance()->is_logged_in()){//Member is logged-in.
35
+ return $fields;
36
+ }
37
+
38
+ //Member is not logged-in so show the protection message.
39
+ $fields = array();
40
+ $login_link = SwpmUtils::_('Please Login to Comment.');
41
+ $fields['comment_field'] = $login_link;
42
+ $fields['title_reply'] = '';
43
+ $fields['cancel_reply_link'] = '';
44
+ $fields['comment_notes_before'] = '';
45
+ $fields['comment_notes_after'] = '';
46
+ $fields['fields'] = '';
47
+ $fields['label_submit'] = '';
48
+ $fields['title_reply_to'] = '';
49
+ $fields['id_submit'] = '';
50
+ $fields['id_form'] = '';
51
+
52
+ return $fields;
53
+ }
54
+
55
+ /*
56
+ * This function checks and restricts comment posting (via HTTP POST) to members only (if the feature is enabled)
57
+ */
58
+ public static function check_and_restrict_comment_posting_to_members(){
59
+ $allow_comments = SwpmSettings::get_instance()->get_value('members-login-to-comment');
60
+ if (empty($allow_comments)){
61
+ return;
62
+ }
63
+
64
+ if (is_admin()) {
65
+ return;
66
+ }
67
+
68
+ if (SwpmAuth::get_instance()->is_logged_in()){
69
+ return;
70
+ }
71
+
72
+ $comment_id = filter_input(INPUT_POST, 'comment_post_ID');
73
+ if (empty($comment_id)) {
74
+ return;
75
+ }
76
+
77
+ //Stop this request -> 1)we are on the front-side. 2) Comment posted by a not logged in member. 3) comment_post_ID missing.
78
+ $_POST = array();
79
+ wp_die(SwpmUtils::_('Comments not allowed by a non-member.'));
80
+ }
81
+
82
+ }
classes/class.swpm-init-time-tasks.php CHANGED
@@ -27,7 +27,7 @@ class SwpmInitTimeTasks {
27
  $this->admin_init();
28
  }
29
 
30
- //Do frontend-only init time taks
31
  if (!is_admin()) {
32
  SwpmAuth::get_instance();
33
  $this->verify_and_delete_account();
@@ -41,6 +41,7 @@ class SwpmInitTimeTasks {
41
  $this->process_password_reset();
42
  $this->register_member();
43
  $this->edit_profile();
 
44
  }
45
 
46
  //IPN listener
27
  $this->admin_init();
28
  }
29
 
30
+ //Do frontend-only init time tasks
31
  if (!is_admin()) {
32
  SwpmAuth::get_instance();
33
  $this->verify_and_delete_account();
41
  $this->process_password_reset();
42
  $this->register_member();
43
  $this->edit_profile();
44
+ SwpmCommentFormRelated::check_and_restrict_comment_posting_to_members();
45
  }
46
 
47
  //IPN listener
classes/class.swpm-settings.php CHANGED
@@ -52,13 +52,10 @@ class SwpmSettings {
52
  'options' => SwpmUtils::get_account_state_options(),
53
  'default' => 'active',
54
  'message' => SwpmUtils::_('Select the default account status for newly registered users. If you want to manually approve the members then you can set the status to "Pending".')));
55
- add_settings_field('allow-account-deletion', SwpmUtils::_('Allow Account Deletion'), array(&$this, 'checkbox_callback'), 'simple_wp_membership_settings', 'general-settings', array('item' => 'allow-account-deletion',
56
- 'options' => SwpmUtils::get_account_state_options(),
57
- 'message' => SwpmUtils::_('Allow users to delete their accounts.')));
58
- add_settings_field('delete-pending-account', SwpmUtils::_('Auto Delete Pending Account'), array(&$this, 'selectbox_callback'), 'simple_wp_membership_settings', 'general-settings', array('item' => 'delete-pending-account',
59
- 'options' => array(0 => 'Do not delete', 1 => 'Older than 1 month', 2 => 'Older than 2 months'),
60
- 'default' => '0',
61
- 'message' => SwpmUtils::_('Select how long you want to keep "pending" account.')));
62
  /*
63
  add_settings_field('protect-everything', SwpmUtils::_('Protect Everything'),
64
  array(&$this, 'checkbox_callback'), 'simple_wp_membership_settings', 'general-settings',
@@ -154,6 +151,16 @@ class SwpmSettings {
154
 
155
  add_settings_field('enable-expired-account-login', SwpmUtils::_('Enable Expired Account Login'), array(&$this, 'checkbox_callback'), 'simple_wp_membership_settings', 'advanced-settings', array('item' => 'enable-expired-account-login',
156
  'message' => SwpmUtils::_("When enabled, expired members will be able to log into the system but won't be able to view any protected content. This allows them to easily renew their account by making another payment.")));
 
 
 
 
 
 
 
 
 
 
157
  }
158
 
159
  private function tab_6() {
@@ -301,8 +308,7 @@ class SwpmSettings {
301
  $output['enable-free-membership'] = isset($input['enable-free-membership']) ? esc_attr($input['enable-free-membership']) : "";
302
  $output['enable-moretag'] = isset($input['enable-moretag']) ? esc_attr($input['enable-moretag']) : "";
303
  $output['enable-debug'] = isset($input['enable-debug']) ? esc_attr($input['enable-debug']) : "";
304
- $output['enable-sandbox-testing'] = isset($input['enable-sandbox-testing']) ? esc_attr($input['enable-sandbox-testing']) : "";
305
- $output['allow-account-deletion'] = isset($input['allow-account-deletion']) ? esc_attr($input['allow-account-deletion']) : "";
306
 
307
  $output['free-membership-id'] = ($input['free-membership-id'] != 1) ? absint($input['free-membership-id']) : '';
308
  $output['login-page-url'] = esc_url($input['login-page-url']);
@@ -311,7 +317,7 @@ class SwpmSettings {
311
  $output['reset-page-url'] = esc_url($input['reset-page-url']);
312
  $output['join-us-page-url'] = esc_url($input['join-us-page-url']);
313
  $output['default-account-status'] = esc_attr($input['default-account-status']);
314
- $output['delete-pending-account'] = isset($input['delete-pending-account']) ? esc_attr($input['delete-pending-account']) : 0;
315
 
316
  return $output;
317
  }
@@ -349,6 +355,8 @@ class SwpmSettings {
349
  }
350
  $output = $this->settings;
351
  $output['enable-expired-account-login'] = isset($input['enable-expired-account-login']) ? esc_attr($input['enable-expired-account-login']) : "";
 
 
352
 
353
  return $output;
354
  }
52
  'options' => SwpmUtils::get_account_state_options(),
53
  'default' => 'active',
54
  'message' => SwpmUtils::_('Select the default account status for newly registered users. If you want to manually approve the members then you can set the status to "Pending".')));
55
+
56
+ add_settings_field('members-login-to-comment', SwpmUtils::_('Members Must be Logged in to Comment'), array(&$this, 'checkbox_callback'), 'simple_wp_membership_settings', 'general-settings', array('item' => 'members-login-to-comment',
57
+ 'message' => SwpmUtils::_('Enable this option if you only want the members of the site to be able to post a comment.')));
58
+
 
 
 
59
  /*
60
  add_settings_field('protect-everything', SwpmUtils::_('Protect Everything'),
61
  array(&$this, 'checkbox_callback'), 'simple_wp_membership_settings', 'general-settings',
151
 
152
  add_settings_field('enable-expired-account-login', SwpmUtils::_('Enable Expired Account Login'), array(&$this, 'checkbox_callback'), 'simple_wp_membership_settings', 'advanced-settings', array('item' => 'enable-expired-account-login',
153
  'message' => SwpmUtils::_("When enabled, expired members will be able to log into the system but won't be able to view any protected content. This allows them to easily renew their account by making another payment.")));
154
+
155
+ add_settings_field('allow-account-deletion', SwpmUtils::_('Allow Account Deletion'), array(&$this, 'checkbox_callback'), 'simple_wp_membership_settings', 'advanced-settings', array('item' => 'allow-account-deletion',
156
+ 'options' => SwpmUtils::get_account_state_options(),
157
+ 'message' => SwpmUtils::_('Allow users to delete their accounts.')));
158
+ add_settings_field('delete-pending-account', SwpmUtils::_('Auto Delete Pending Account'), array(&$this, 'selectbox_callback'), 'simple_wp_membership_settings', 'advanced-settings', array('item' => 'delete-pending-account',
159
+ 'options' => array(0 => 'Do not delete', 1 => 'Older than 1 month', 2 => 'Older than 2 months'),
160
+ 'default' => '0',
161
+ 'message' => SwpmUtils::_('Select how long you want to keep "pending" account.')));
162
+
163
+
164
  }
165
 
166
  private function tab_6() {
308
  $output['enable-free-membership'] = isset($input['enable-free-membership']) ? esc_attr($input['enable-free-membership']) : "";
309
  $output['enable-moretag'] = isset($input['enable-moretag']) ? esc_attr($input['enable-moretag']) : "";
310
  $output['enable-debug'] = isset($input['enable-debug']) ? esc_attr($input['enable-debug']) : "";
311
+ $output['enable-sandbox-testing'] = isset($input['enable-sandbox-testing']) ? esc_attr($input['enable-sandbox-testing']) : "";
 
312
 
313
  $output['free-membership-id'] = ($input['free-membership-id'] != 1) ? absint($input['free-membership-id']) : '';
314
  $output['login-page-url'] = esc_url($input['login-page-url']);
317
  $output['reset-page-url'] = esc_url($input['reset-page-url']);
318
  $output['join-us-page-url'] = esc_url($input['join-us-page-url']);
319
  $output['default-account-status'] = esc_attr($input['default-account-status']);
320
+ $output['members-login-to-comment'] = isset($input['members-login-to-comment']) ? esc_attr($input['members-login-to-comment']) : "";
321
 
322
  return $output;
323
  }
355
  }
356
  $output = $this->settings;
357
  $output['enable-expired-account-login'] = isset($input['enable-expired-account-login']) ? esc_attr($input['enable-expired-account-login']) : "";
358
+ $output['allow-account-deletion'] = isset($input['allow-account-deletion']) ? esc_attr($input['allow-account-deletion']) : "";
359
+ $output['delete-pending-account'] = isset($input['delete-pending-account']) ? esc_attr($input['delete-pending-account']) : 0;
360
 
361
  return $output;
362
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: smp7, wp.insider, amijanina
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,
5
  Requires at least: 3.3
6
- Tested up to: 4.4
7
- Stable tag: 3.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -68,6 +68,7 @@ You can create a free forum user account and ask your questions.
68
  * Customize the password reset email for members.
69
  * Use Google reCAPTCHA on your member registration form.
70
  * The login and registration widgets will be responsive if you are using a responsive theme.
 
71
  * Front-end member registration page.
72
  * Front-end member profiles.
73
  * Front-end member login page.
@@ -121,6 +122,12 @@ https://simple-membership-plugin.com/
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
 
124
  = 3.2.1 =
125
  - Added a new filter (swpm_transactions_menu_items_per_page) that can be used to customize the number of items that is listed in the transactions menu.
126
  - Added more sorting option in the transactions table.
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,
5
  Requires at least: 3.3
6
+ Tested up to: 4.5
7
+ Stable tag: 3.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
68
  * Customize the password reset email for members.
69
  * Use Google reCAPTCHA on your member registration form.
70
  * The login and registration widgets will be responsive if you are using a responsive theme.
71
+ * Ability to restrict the commenting feature on your site to your members only.
72
  * Front-end member registration page.
73
  * Front-end member profiles.
74
  * Front-end member login page.
122
 
123
  == Changelog ==
124
 
125
+ = 3.2.2 =
126
+ - New feature to only allow the members of the site to be able to post a comment.
127
+ - Moved the "Allow Account Deletion" option to the Advanced Settings tab of the plugin.
128
+ - Moved the "Auto Delete Pending Account" option to the Advanced Settings tab of the plugin.
129
+ - WordPress 4.5 compatibility.
130
+
131
  = 3.2.1 =
132
  - Added a new filter (swpm_transactions_menu_items_per_page) that can be used to customize the number of items that is listed in the transactions menu.
133
  - Added more sorting option in the transactions table.
simple-wp-membership.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Simple WordPress Membership
4
- Version: 3.2.1
5
  Plugin URI: https://simple-membership-plugin.com/
6
  Author: smp7, wp.insider
7
  Author URI: https://simple-membership-plugin.com/
@@ -17,7 +17,7 @@ include_once('classes/class.simple-wp-membership.php');
17
  include_once('classes/class.swpm-cronjob.php');
18
  include_once('swpm-compat.php');
19
 
20
- define('SIMPLE_WP_MEMBERSHIP_VER', '3.2.1');
21
  define('SIMPLE_WP_MEMBERSHIP_DB_VER', '1.2');
22
  define('SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url());
23
  define('SIMPLE_WP_MEMBERSHIP_PATH', dirname(__FILE__) . '/');
1
  <?php
2
  /*
3
  Plugin Name: Simple WordPress Membership
4
+ Version: 3.2.2
5
  Plugin URI: https://simple-membership-plugin.com/
6
  Author: smp7, wp.insider
7
  Author URI: https://simple-membership-plugin.com/
17
  include_once('classes/class.swpm-cronjob.php');
18
  include_once('swpm-compat.php');
19
 
20
+ define('SIMPLE_WP_MEMBERSHIP_VER', '3.2.2');
21
  define('SIMPLE_WP_MEMBERSHIP_DB_VER', '1.2');
22
  define('SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url());
23
  define('SIMPLE_WP_MEMBERSHIP_PATH', dirname(__FILE__) . '/');