WP-Members Membership Plugin - Version 3.1.7

Version Description

  • API updates: added wpmem_is_user_activated().
  • API updates: wpmem_is_reg_page() added default of current page ID.
  • API updates: wpmem_current_url() added check for query string.
  • API updates: Added wpmem_fields filter to wpmem_fields().
  • API updates: Added wpmem_current_post_id() and wpmem_form_label() functions.
  • API updates: Added new [wpmem_avatar], [wpmem_login_link], and [wpmem_register_link] shortcodes.
  • API updates: Added filter option in user export to decode html entities in user fields.
  • API updates: Added wpmem_get_action action hook when wpmem_a is loaded.
  • All admin dependencies and actions/filters loaded in admin api object.
  • Corrected issue in forms function were RS Captcha had empty div wrapper variable.
  • Removed deprecated functions wpmem_load_admin_js(), wpmem_test_shortcode(), and wpmem_generatePassword().
  • Moved remaining deprecated functions to new inc/deprecated.php.
  • Added successful registration message on page if nonce validates (for reg redirects).
  • Added User object class, handling login, logout, register.
  • Added buffering to login form and widget to allow do_login action results to be displayed (such as 3rd party login captcha).
  • Added support for WP's login_redirect filter (loads before wpmem_login_redirect).
  • Added a div wrapper for post restricted message.
  • Added initial form support for HTML5 number input, & min, max, title, and pattern attributes (placeholder support was added in 3.1.6).
  • Updated wpmem_admin_update() to exit if there is no user ID.
  • Updated admin notification email to translate field labels.
  • Updated login form links and filters to a single process (was one for each).
  • Updated WP Registration finalize process.
  • Moved form building functions to forms object class.
  • Deprecated wpmem_register_fields_arr filter (Use wpmem_fields instead).
  • Removing the wpautop() function is now optional rather than default.
  • Fixed load fields error checking, install function now correctly returns defaults.
  • Changed password reset and password change to use wp_set_password() for improved performance with caching.
Download this release

Release Info

Developer cbutlerjr
Plugin Icon 128x128 WP-Members Membership Plugin
Version 3.1.7
Comparing to
See all releases

Code changes from version 3.1.6 to 3.1.7

admin/admin.php CHANGED
@@ -6,17 +6,16 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_a_do_field_reorder
18
  * - wpmem_admin_plugin_links
19
- * - wpmem_load_admin_js
20
  * - wpmem_a_captcha_tab
21
  * - wpmem_add_captcha_tab
22
  * - wpmem_admin
@@ -27,28 +26,12 @@
27
  * - wpmem_admin_enqueue_scripts
28
  */
29
 
30
-
31
- /**
32
- * Actions and Filters
33
- */
34
- add_action( 'admin_enqueue_scripts', 'wpmem_admin_enqueue_scripts' );
35
- add_action( 'wpmem_admin_do_tab', 'wpmem_admin_do_tab' );
36
- add_action( 'wp_ajax_wpmem_a_field_reorder', 'wpmem_a_do_field_reorder' );
37
- add_action( 'user_new_form', 'wpmem_admin_add_new_user' );
38
- add_filter( 'plugin_action_links', 'wpmem_admin_plugin_links', 10, 2 );
39
-
40
-
41
  /**
42
  * Calls the function to reorder fields.
43
  *
44
  * @since 2.8.0
45
  */
46
  function wpmem_a_do_field_reorder() {
47
- /**
48
- * Load the fields tab functions.
49
- */
50
- include_once( WPMEM_PATH . 'admin/tab-fields.php' );
51
-
52
  // Reorder registration fields.
53
  wpmem_a_field_reorder();
54
  }
@@ -76,20 +59,6 @@ function wpmem_admin_plugin_links( $links, $file ) {
76
  }
77
 
78
 
79
- /**
80
- * Loads the admin javascript and css files.
81
- *
82
- * @since 2.5.1
83
- * @deprecated 3.0.6 Replaced by wpmem_admin_enqueue_scripts().
84
- */
85
- function wpmem_load_admin_js() {
86
- wpmem_write_log( "wpmem_load_admin_js() is deprecated as of WP-Members 3.0.6" );
87
- // Queue up admin ajax and styles.
88
- wp_enqueue_script( 'wpmem-admin-js', WPMEM_DIR . 'admin/js/admin.js', '', WPMEM_VERSION );
89
- wp_enqueue_style ( 'wpmem-admin-css', WPMEM_DIR . 'admin/css/admin.css', '', WPMEM_VERSION );
90
- }
91
-
92
-
93
  /**
94
  * Creates the captcha tab.
95
  *
@@ -266,10 +235,6 @@ function wpmem_admin_action( $action ) {
266
  * @since 2.9.1
267
  */
268
  function wpmem_admin_add_new_user() {
269
- /**
270
- * Load WP native registration functions.
271
- */
272
- include_once( WPMEM_PATH . 'inc/wp-registration.php' );
273
  // Output the custom registration fields.
274
  echo wpmem_do_wp_newuser_form();
275
  return;
@@ -282,10 +247,12 @@ function wpmem_admin_add_new_user() {
282
  * Only loads the js and css on admin screens that use them.
283
  *
284
  * @since 3.0.6
 
285
  *
286
  * @param str $hook The admin screen hook being loaded.
287
  */
288
  function wpmem_admin_enqueue_scripts( $hook ) {
 
289
  if ( $hook == 'edit.php' || $hook == 'settings_page_wpmem-settings' ) {
290
  wp_enqueue_style( 'wpmem-admin', WPMEM_DIR . 'admin/css/admin.css', '', WPMEM_VERSION );
291
  }
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_a_do_field_reorder
18
  * - wpmem_admin_plugin_links
 
19
  * - wpmem_a_captcha_tab
20
  * - wpmem_add_captcha_tab
21
  * - wpmem_admin
26
  * - wpmem_admin_enqueue_scripts
27
  */
28
 
 
 
 
 
 
 
 
 
 
 
 
29
  /**
30
  * Calls the function to reorder fields.
31
  *
32
  * @since 2.8.0
33
  */
34
  function wpmem_a_do_field_reorder() {
 
 
 
 
 
35
  // Reorder registration fields.
36
  wpmem_a_field_reorder();
37
  }
59
  }
60
 
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**
63
  * Creates the captcha tab.
64
  *
235
  * @since 2.9.1
236
  */
237
  function wpmem_admin_add_new_user() {
 
 
 
 
238
  // Output the custom registration fields.
239
  echo wpmem_do_wp_newuser_form();
240
  return;
247
  * Only loads the js and css on admin screens that use them.
248
  *
249
  * @since 3.0.6
250
+ * @deprecated 3.1.7 Use wpmem_dashboard_enqueue_scripts() instead.
251
  *
252
  * @param str $hook The admin screen hook being loaded.
253
  */
254
  function wpmem_admin_enqueue_scripts( $hook ) {
255
+ wpmem_write_log( "wpmem_admin_enqueue_scripts() is deprecated as of WP-Members 3.1.7. Use wpmem_dashboard_enqueue_scripts() instead" );
256
  if ( $hook == 'edit.php' || $hook == 'settings_page_wpmem-settings' ) {
257
  wp_enqueue_style( 'wpmem-admin', WPMEM_DIR . 'admin/css/admin.css', '', WPMEM_VERSION );
258
  }
admin/dialogs.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_a_do_warnings
@@ -22,13 +22,6 @@
22
  * - butlerblog_feed_output
23
  */
24
 
25
-
26
- // Actions.
27
- if ( ! is_multisite() ) {
28
- add_action('wp_dashboard_setup', 'butlerblog_dashboard_widget');
29
- }
30
-
31
-
32
  /**
33
  * Outputs the various admin warning messages.
34
  *
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_a_do_warnings
22
  * - butlerblog_feed_output
23
  */
24
 
 
 
 
 
 
 
 
25
  /**
26
  * Outputs the various admin warning messages.
27
  *
admin/includes/api.php CHANGED
@@ -4,12 +4,12 @@
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at http://rocketgeek.com
7
- * Copyright (c) 2006-2016 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @author Chad Butler
12
- * @copyright 2006-2016
13
  *
14
  * Functions included:
15
  * - wpmem_add_custom_email
@@ -70,4 +70,16 @@ function wpmem_add_custom_dialog( $dialogs, $tag, $msg, $label ) {
70
  */
71
  function wpmem_is_tab( $tab ) {
72
  return ( $tab == wpmem_get( 'tab', false, 'get' ) ) ? true : false;
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at http://rocketgeek.com
7
+ * Copyright (c) 2006-2017 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @author Chad Butler
12
+ * @copyright 2006-2017
13
  *
14
  * Functions included:
15
  * - wpmem_add_custom_email
70
  */
71
  function wpmem_is_tab( $tab ) {
72
  return ( $tab == wpmem_get( 'tab', false, 'get' ) ) ? true : false;
73
+ }
74
+
75
+ /**
76
+ * Utility function generates link to user profile.
77
+ *
78
+ * @since 3.1.7
79
+ *
80
+ * @param int $user_id
81
+ * @return string user profile URL.
82
+ */
83
+ function wpmem_admin_user_profile( $user_id ) {
84
+ return add_query_arg( 'user_id', $user_id, admin_url( 'user-edit.php' ) );
85
+ }
admin/includes/class-wp-members-admin-api.php CHANGED
@@ -64,6 +64,7 @@ class WP_Members_Admin_API {
64
  *
65
  * @since 3.1.0
66
  * @since 3.1.1 Added tab-about.php.
 
67
  */
68
  function load_dependencies() {
69
  if ( is_multisite() && current_user_can( 'edit_theme_options' ) ) {
@@ -76,7 +77,6 @@ class WP_Members_Admin_API {
76
  if ( current_user_can( 'manage_options' ) ) {
77
  require_once( WPMEM_PATH . 'admin/tab-options.php' );
78
  require_once( WPMEM_PATH . 'admin/tab-fields.php' );
79
- require_once( WPMEM_PATH . 'admin/tab-dialogs.php' );
80
  require_once( WPMEM_PATH . 'admin/tab-emails.php' );
81
  require_once( WPMEM_PATH . 'admin/tab-captcha.php' );
82
  require_once( WPMEM_PATH . 'admin/tab-about.php' );
@@ -85,28 +85,53 @@ class WP_Members_Admin_API {
85
  if ( current_user_can( 'edit_posts' ) ) {
86
  require_once( WPMEM_PATH . 'admin/post.php' );
87
  }
 
88
  require_once( WPMEM_PATH . 'inc/users.php' );
89
  require_once( WPMEM_PATH . 'admin/users.php' );
90
  require_once( WPMEM_PATH . 'admin/includes/api.php' );
 
91
  }
92
 
93
  /**
94
  * Load admin.
95
  *
96
  * @since 3.1.0
 
97
  */
98
  function load_hooks() {
99
 
 
 
 
 
 
 
 
 
100
  // If user has a role that cannot edit users, set profile actions for non-admins.
101
  if ( ! current_user_can( 'edit_users' ) ) {
102
  // User actions and filters.
103
- add_action( 'show_user_profile', 'wpmem_user_profile' );
104
- add_action( 'edit_user_profile', 'wpmem_user_profile' );
105
- add_action( 'profile_update', 'wpmem_profile_update' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
 
108
  // If user has a role that can edit posts, add the block/unblock meta boxes and custom post/page columns.
109
- if ( current_user_can( 'edit_posts' ) ) {
110
  // Post actions and filters.
111
  add_action( 'add_meta_boxes', 'wpmem_block_meta_add' );
112
  add_action( 'save_post', 'wpmem_block_meta_save' );
@@ -118,7 +143,18 @@ class WP_Members_Admin_API {
118
  add_action( 'wpmem_admin_after_profile', 'wpmem_profile_show_activate', 7 );
119
  add_action( 'wpmem_admin_after_profile', 'wpmem_profile_show_expiration', 8 );
120
  add_action( 'wpmem_admin_after_profile', 'wpmem_profile_show_ip', 9 );
 
 
 
 
 
 
121
  }
 
 
 
 
 
122
  } // End of load_hooks()
123
 
124
  /**
@@ -266,18 +302,20 @@ class WP_Members_Admin_API {
266
  */
267
  function add_dialog( $args ) {
268
  global $wpmem;
269
- $defaults = array(
270
- 'name' => $args['name'],
271
- 'label' => $args['label'],
272
- //'input' => $args['name'] . '_dialog',
273
- 'value' => $args['value'],
274
- //'value' => ( $args['value'] ) ? $args['value'] : $wpmem->get_text( $key ),
275
- );
276
-
277
- // Merge args with settings.
278
- $args = wp_parse_args( $args, $defaults );
279
-
280
- $this->dialogs[ $args['name'] ] = $args;
 
 
281
 
282
  //return $args;
283
  }
64
  *
65
  * @since 3.1.0
66
  * @since 3.1.1 Added tab-about.php.
67
+ * @since 3.1.7 Loads all admin dependent files.
68
  */
69
  function load_dependencies() {
70
  if ( is_multisite() && current_user_can( 'edit_theme_options' ) ) {
77
  if ( current_user_can( 'manage_options' ) ) {
78
  require_once( WPMEM_PATH . 'admin/tab-options.php' );
79
  require_once( WPMEM_PATH . 'admin/tab-fields.php' );
 
80
  require_once( WPMEM_PATH . 'admin/tab-emails.php' );
81
  require_once( WPMEM_PATH . 'admin/tab-captcha.php' );
82
  require_once( WPMEM_PATH . 'admin/tab-about.php' );
85
  if ( current_user_can( 'edit_posts' ) ) {
86
  require_once( WPMEM_PATH . 'admin/post.php' );
87
  }
88
+ require_once( WPMEM_PATH . 'admin/tab-dialogs.php' );
89
  require_once( WPMEM_PATH . 'inc/users.php' );
90
  require_once( WPMEM_PATH . 'admin/users.php' );
91
  require_once( WPMEM_PATH . 'admin/includes/api.php' );
92
+ include_once( WPMEM_PATH . 'inc/wp-registration.php' );
93
  }
94
 
95
  /**
96
  * Load admin.
97
  *
98
  * @since 3.1.0
99
+ * @since 3.1.7 Loads all admin hooks.
100
  */
101
  function load_hooks() {
102
 
103
+ add_action( 'admin_enqueue_scripts', 'wpmem_dashboard_enqueue_scripts' );
104
+ add_action( 'wpmem_admin_do_tab', 'wpmem_admin_do_tab' );
105
+ add_action( 'wp_ajax_wpmem_a_field_reorder', 'wpmem_a_do_field_reorder' );
106
+ add_action( 'user_new_form', 'wpmem_admin_add_new_user' );
107
+ add_filter( 'plugin_action_links', 'wpmem_admin_plugin_links', 10, 2 );
108
+ add_filter( 'wpmem_admin_tabs', 'wpmem_add_about_tab' );
109
+ add_action( 'wpmem_admin_do_tab', 'wpmem_a_about_tab', 999, 1 );
110
+
111
  // If user has a role that cannot edit users, set profile actions for non-admins.
112
  if ( ! current_user_can( 'edit_users' ) ) {
113
  // User actions and filters.
114
+ add_action( 'show_user_profile', 'wpmem_user_profile' );
115
+ add_action( 'edit_user_profile', 'wpmem_user_profile' );
116
+ add_action( 'profile_update', 'wpmem_profile_update' );
117
+ } else {
118
+ add_action( 'show_user_profile', 'wpmem_admin_fields' );
119
+ add_action( 'edit_user_profile', 'wpmem_admin_fields' );
120
+ add_action( 'profile_update', 'wpmem_admin_update' );
121
+ add_action( 'admin_footer-users.php', 'wpmem_bulk_user_action' );
122
+ add_action( 'load-users.php', 'wpmem_users_page_load' );
123
+ add_action( 'admin_notices', 'wpmem_users_admin_notices' );
124
+ add_filter( 'views_users', 'wpmem_users_views' );
125
+ add_filter( 'manage_users_columns', 'wpmem_add_user_column' );
126
+ add_action( 'manage_users_custom_column', 'wpmem_add_user_column_content', 10, 3 );
127
+ add_action( 'wpmem_post_register_data', 'wpmem_set_new_user_non_active' );
128
+ add_action( 'wpmem_user_activated', 'wpmem_set_activated_user' );
129
+ add_action( 'wpmem_user_deactivated', 'wpmem_set_deactivated_user' );
130
+ add_filter( 'user_row_actions', 'wpmem_insert_activate_link', 10, 2 );
131
  }
132
 
133
  // If user has a role that can edit posts, add the block/unblock meta boxes and custom post/page columns.
134
+ if ( current_user_can( 'edit_posts' ) ) {
135
  // Post actions and filters.
136
  add_action( 'add_meta_boxes', 'wpmem_block_meta_add' );
137
  add_action( 'save_post', 'wpmem_block_meta_save' );
143
  add_action( 'wpmem_admin_after_profile', 'wpmem_profile_show_activate', 7 );
144
  add_action( 'wpmem_admin_after_profile', 'wpmem_profile_show_expiration', 8 );
145
  add_action( 'wpmem_admin_after_profile', 'wpmem_profile_show_ip', 9 );
146
+
147
+ add_action( 'admin_footer-edit.php', 'wpmem_bulk_posts_action' );
148
+ add_action( 'load-edit.php', 'wpmem_posts_page_load' );
149
+ add_action( 'admin_notices', 'wpmem_posts_admin_notices' );
150
+ add_action( 'load-post.php', 'wpmem_load_tinymce' );
151
+ add_action( 'load-post-new.php', 'wpmem_load_tinymce' );
152
  }
153
+
154
+ if ( ! is_multisite() && current_user_can( 'manage_options' ) ) {
155
+ add_action('wp_dashboard_setup', 'butlerblog_dashboard_widget');
156
+ }
157
+
158
  } // End of load_hooks()
159
 
160
  /**
302
  */
303
  function add_dialog( $args ) {
304
  global $wpmem;
305
+ if ( is_array( $args ) && isset( $args['label'] ) ) {
306
+ $defaults = array(
307
+ 'name' => $args['name'],
308
+ 'label' => $args['label'],
309
+ //'input' => $args['name'] . '_dialog',
310
+ 'value' => $args['value'],
311
+ //'value' => ( $args['value'] ) ? $args['value'] : $wpmem->get_text( $key ),
312
+ );
313
+
314
+ // Merge args with settings.
315
+ $args = wp_parse_args( $args, $defaults );
316
+
317
+ $this->dialogs[ $args['name'] ] = $args;
318
+ }
319
 
320
  //return $args;
321
  }
admin/post.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_bulk_posts_action
@@ -25,17 +25,6 @@
25
  * - wpmem_load_tinymce
26
  */
27
 
28
-
29
- /**
30
- * Actions
31
- */
32
- add_action( 'admin_footer-edit.php', 'wpmem_bulk_posts_action' );
33
- add_action( 'load-edit.php', 'wpmem_posts_page_load' );
34
- add_action( 'admin_notices', 'wpmem_posts_admin_notices' );
35
- add_action( 'load-post.php', 'wpmem_load_tinymce' );
36
- add_action( 'load-post-new.php', 'wpmem_load_tinymce' );
37
-
38
-
39
  /**
40
  * Function to add block/unblock to the bulk dropdown list.
41
  *
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_bulk_posts_action
25
  * - wpmem_load_tinymce
26
  */
27
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Function to add block/unblock to the bulk dropdown list.
30
  *
admin/tab-about.php CHANGED
@@ -1,12 +1,5 @@
1
  <?php
2
 
3
- /**
4
- * Filters and Actions.
5
- */
6
- add_filter( 'wpmem_admin_tabs', 'wpmem_add_about_tab' );
7
- add_action( 'wpmem_admin_do_tab', 'wpmem_a_about_tab', 999, 1 );
8
-
9
-
10
  /**
11
  * Creates the About tab.
12
  *
1
  <?php
2
 
 
 
 
 
 
 
 
3
  /**
4
  * Creates the About tab.
5
  *
admin/tab-captcha.php CHANGED
@@ -6,13 +6,13 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WordPress
13
  * @subpackage WP-Members
14
  * @author Chad Butler
15
- * @copyright 2006-2016
16
  *
17
  * Functions included:
18
  * - wpmem_a_build_captcha_options
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WordPress
13
  * @subpackage WP-Members
14
  * @author Chad Butler
15
+ * @copyright 2006-2017
16
  *
17
  * Functions included:
18
  * - wpmem_a_build_captcha_options
admin/tab-dialogs.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_dialogs
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_dialogs
admin/tab-emails.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_emails
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_emails
admin/tab-fields.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  */
16
 
17
 
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  */
16
 
17
 
admin/tab-options.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_options
@@ -394,12 +394,12 @@ function wpmem_update_options() {
394
 
395
  $wpmem_newsettings = array(
396
  'version' => WPMEM_VERSION,
397
- 'notify' => wpmem_get( 'wpmem_settings_notify', 0 ),//( isset( $_POST['wpmem_settings_notify'] ) ) ? $_POST['wpmem_settings_notify'] : 0,
398
- 'mod_reg' => wpmem_get( 'wpmem_settings_moderate', 0 ),//( isset( $_POST['wpmem_settings_moderate'] ) ) ? $_POST['wpmem_settings_moderate'] : 0,
399
- 'captcha' => wpmem_get( 'wpmem_settings_captcha', 0 ),//( isset( $_POST['wpmem_settings_captcha'] ) ) ? $_POST['wpmem_settings_captcha'] : 0,
400
- 'use_exp' => wpmem_get( 'wpmem_settings_time_exp', 0 ),//( isset( $_POST['wpmem_settings_time_exp'] ) ) ? $_POST['wpmem_settings_time_exp'] : 0,
401
- 'use_trial' => wpmem_get( 'wpmem_settings_trial', 0 ),//( isset( $_POST['wpmem_settings_trial'] ) ) ? $_POST['wpmem_settings_trial'] : 0,
402
- 'warnings' => wpmem_get( 'wpmem_settings_ignore_warnings', 0 ),//( isset( $_POST['wpmem_settings_ignore_warnings'] ) ) ? $_POST['wpmem_settings_ignore_warnings'] : 0,
403
  'user_pages' => array(
404
  'profile' => ( $msurl ) ? $msurl : '',
405
  'register' => ( $regurl ) ? $regurl : '',
@@ -407,7 +407,7 @@ function wpmem_update_options() {
407
  ),
408
  'cssurl' => ( $cssurl ) ? $cssurl : '',
409
  'style' => $wpmem_settings_style,
410
- 'attrib' => wpmem_get( 'attribution', 0 ),//( isset( $_POST['attribution'] ) ) ? $_POST['attribution'] : 0,
411
  );
412
 
413
  // Build an array of post types
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_options
394
 
395
  $wpmem_newsettings = array(
396
  'version' => WPMEM_VERSION,
397
+ 'notify' => wpmem_get( 'wpmem_settings_notify', 0 ),
398
+ 'mod_reg' => wpmem_get( 'wpmem_settings_moderate', 0 ),
399
+ 'captcha' => wpmem_get( 'wpmem_settings_captcha', 0 ),
400
+ 'use_exp' => wpmem_get( 'wpmem_settings_time_exp', 0 ),
401
+ 'use_trial' => wpmem_get( 'wpmem_settings_trial', 0 ),
402
+ 'warnings' => wpmem_get( 'wpmem_settings_ignore_warnings', 0 ),
403
  'user_pages' => array(
404
  'profile' => ( $msurl ) ? $msurl : '',
405
  'register' => ( $regurl ) ? $regurl : '',
407
  ),
408
  'cssurl' => ( $cssurl ) ? $cssurl : '',
409
  'style' => $wpmem_settings_style,
410
+ 'attrib' => wpmem_get( 'attribution', 0 ),
411
  );
412
 
413
  // Build an array of post types
admin/user-export.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-20165
15
  */
16
 
17
 
@@ -35,6 +35,7 @@ function wpmem_export_users( $args, $users = null ) {
35
  'filename' => 'wp-members-user-export-' . $today . '.csv',
36
  'export_fields' => wpmem_fields(), //array(),
37
  'exclude_fields' => array( 'password', 'confirm_password', 'confirm_email' ),
 
38
  );
39
 
40
  // Merge $args with defaults.
@@ -97,10 +98,12 @@ function wpmem_export_users( $args, $users = null ) {
97
  foreach ( $args['export_fields'] as $meta => $field ) {
98
  if ( ! in_array( $meta, $args['exclude_fields'] ) ) {
99
  // @todo Research using fputcsv to escape fields for export.
100
- if ( in_array( $meta, $wp_user_fields ) ){
101
  $data .= '"' . $user_info->{$meta} . '",';
102
  } else {
103
- $data .= '"' . get_user_meta( $user, $meta, true ) . '",';
 
 
104
  }
105
  }
106
  }
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  */
16
 
17
 
35
  'filename' => 'wp-members-user-export-' . $today . '.csv',
36
  'export_fields' => wpmem_fields(), //array(),
37
  'exclude_fields' => array( 'password', 'confirm_password', 'confirm_email' ),
38
+ 'entity_decode' => false,
39
  );
40
 
41
  // Merge $args with defaults.
98
  foreach ( $args['export_fields'] as $meta => $field ) {
99
  if ( ! in_array( $meta, $args['exclude_fields'] ) ) {
100
  // @todo Research using fputcsv to escape fields for export.
101
+ if ( in_array( $meta, $wp_user_fields ) ) {
102
  $data .= '"' . $user_info->{$meta} . '",';
103
  } else {
104
+ $raw_data = get_user_meta( $user, $meta, true );
105
+ $formatted = ( $args['entity_decode'] ) ? html_entity_decode( $raw_data ) : $raw_data;
106
+ $data .= '"' . $formatted . '",';
107
  }
108
  }
109
  }
admin/user-profile.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_admin_fields
@@ -21,13 +21,6 @@
21
  * - wpmem_profile_show_ip
22
  */
23
 
24
-
25
- /** Actions */
26
- add_action( 'show_user_profile', 'wpmem_admin_fields' );
27
- add_action( 'edit_user_profile', 'wpmem_admin_fields' );
28
- add_action( 'profile_update', 'wpmem_admin_update' );
29
-
30
-
31
  /**
32
  * Add WP-Members fields to the WP user profile screen.
33
  *
@@ -53,7 +46,7 @@ function wpmem_admin_fields() {
53
  <table class="form-table">
54
  <?php
55
  // Get fields.
56
- $wpmem_fields = wpmem_fields();
57
  // Get excluded meta.
58
  $exclude = wpmem_get_excluded_meta( 'admin-profile' );
59
 
@@ -199,13 +192,20 @@ function wpmem_admin_fields() {
199
  * Updates WP-Members fields from the WP user profile screen.
200
  *
201
  * @since 2.1
 
 
202
  */
203
  function wpmem_admin_update() {
204
 
 
 
 
 
 
 
 
205
  global $wpmem;
206
-
207
- $user_id = $_REQUEST['user_id'];
208
- $wpmem_fields = wpmem_fields();
209
 
210
  /**
211
  * Fires before the user profile is updated.
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_admin_fields
21
  * - wpmem_profile_show_ip
22
  */
23
 
 
 
 
 
 
 
 
24
  /**
25
  * Add WP-Members fields to the WP user profile screen.
26
  *
46
  <table class="form-table">
47
  <?php
48
  // Get fields.
49
+ $wpmem_fields = wpmem_fields( 'admin_profile' );
50
  // Get excluded meta.
51
  $exclude = wpmem_get_excluded_meta( 'admin-profile' );
52
 
192
  * Updates WP-Members fields from the WP user profile screen.
193
  *
194
  * @since 2.1
195
+ *
196
+ * @global object $wpmem
197
  */
198
  function wpmem_admin_update() {
199
 
200
+ $user_id = wpmem_get( 'user_id', false, 'request' ); //$_REQUEST['user_id'];
201
+
202
+ if ( ! $user_id ) {
203
+ // With no user id, no user can be updated.
204
+ return;
205
+ }
206
+
207
  global $wpmem;
208
+ $wpmem_fields = wpmem_fields( 'admin_profile_update' );
 
 
209
 
210
  /**
211
  * Fires before the user profile is updated.
admin/users.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_bulk_user_action
@@ -30,22 +30,6 @@
30
  * - wpmem_set_user_status
31
  */
32
 
33
-
34
- /**
35
- * Actions and filters
36
- */
37
- add_action( 'admin_footer-users.php', 'wpmem_bulk_user_action' );
38
- add_action( 'load-users.php', 'wpmem_users_page_load' );
39
- add_action( 'admin_notices', 'wpmem_users_admin_notices' );
40
- add_filter( 'views_users', 'wpmem_users_views' );
41
- add_filter( 'manage_users_columns', 'wpmem_add_user_column' );
42
- add_action( 'manage_users_custom_column', 'wpmem_add_user_column_content', 10, 3 );
43
- add_action( 'wpmem_post_register_data', 'wpmem_set_new_user_non_active' );
44
- add_action( 'wpmem_user_activated', 'wpmem_set_activated_user' );
45
- add_action( 'wpmem_user_deactivated', 'wpmem_set_deactivated_user' );
46
- add_filter( 'user_row_actions', 'wpmem_insert_activate_link', 10, 2 );
47
-
48
-
49
  /**
50
  * Function to add activate/export to the bulk dropdown list.
51
  *
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_bulk_user_action
30
  * - wpmem_set_user_status
31
  */
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  /**
34
  * Function to add activate/export to the bulk dropdown list.
35
  *
css/generic-no-float.css CHANGED
@@ -5,13 +5,13 @@
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at http://rocketgeek.com
8
- * Copyright (c) 2006-2015 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
  * @package WordPress
12
  * @subpackage WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2015
15
  */
16
 
17
  /*
@@ -88,6 +88,11 @@ see http://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
88
  line-height: 1.5;
89
  }
90
 
 
 
 
 
 
91
  #wpmem_reg input[type="text"],
92
  #wpmem_reg input[type="password"],
93
  #wpmem_reg input[type="email"],
@@ -250,8 +255,7 @@ see http://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
250
  }
251
 
252
  #wpmem_reg label.text, #wpmem_reg label.checkbox,
253
- #wpmem_reg label.textarea , #wpmem_reg label.select,
254
- #wpmem_login label {
255
  width: 90%;
256
  padding: 5px 0 0 0;
257
  }
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at http://rocketgeek.com
8
+ * Copyright (c) 2006-2017 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
  * @package WordPress
12
  * @subpackage WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  */
16
 
17
  /*
88
  line-height: 1.5;
89
  }
90
 
91
+ #wpmem_reg label,
92
+ #wpmem_login label {
93
+ display: initial;
94
+ }
95
+
96
  #wpmem_reg input[type="text"],
97
  #wpmem_reg input[type="password"],
98
  #wpmem_reg input[type="email"],
255
  }
256
 
257
  #wpmem_reg label.text, #wpmem_reg label.checkbox,
258
+ #wpmem_reg label.textarea , #wpmem_reg label.select {
 
259
  width: 90%;
260
  padding: 5px 0 0 0;
261
  }
css/generic-rigid.css CHANGED
@@ -5,13 +5,13 @@
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at http://rocketgeek.com
8
- * Copyright (c) 2006-2016 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
  * @package WordPress
12
  * @subpackage WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  */
16
 
17
  /*
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at http://rocketgeek.com
8
+ * Copyright (c) 2006-2017 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
  * @package WordPress
12
  * @subpackage WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  */
16
 
17
  /*
inc/api.php CHANGED
@@ -4,13 +4,13 @@
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at http://rocketgeek.com
7
- * Copyright (c) 2006-2016 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
- * @copyright 2006-2016
14
  *
15
  * Functions included:
16
  * - wpmem_redirect_to_login
@@ -19,6 +19,8 @@
19
  * - wpmem_register_url
20
  * - wpmem_profile_url
21
  * - wpmem_current_url
 
 
22
  * - wpmem_fields
23
  * - wpmem_gettext
24
  * - wpmem_use_custom_dialog
@@ -30,6 +32,8 @@
30
  * - wpmem_load_dropins
31
  * - wpmem_loginout
32
  * - wpmem_array_insert
 
 
33
  */
34
 
35
  /**
@@ -141,15 +145,19 @@ function wpmem_user_pages() {
141
  * Returns the current full url.
142
  *
143
  * @since 3.1.1
 
144
  *
145
  * @global object $wp
146
  * @param boolean $slash Trailing slash the end of the url (default:true).
 
147
  * @return string $url The current page full url path.
148
  */
149
- function wpmem_current_url( $slash = true ) {
150
  global $wp;
151
  $url = home_url( add_query_arg( array(), $wp->request ) );
152
- return ( $slash ) ? trailingslashit( $url ) : $url;
 
 
153
  }
154
 
155
  /**
@@ -158,13 +166,18 @@ function wpmem_current_url( $slash = true ) {
158
  * @since 3.1.2
159
  *
160
  * @param array $args {
161
- * @type string $name (required) The field meta key.
162
- * @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
163
- * @type string $value (required) The field's value (can be a null value).
164
- * @type string $compare (required) Compare value.
165
- * @type string $class (optional) Class identifier for the field.
166
- * @type boolean $required (optional) If a value is required default: true).
167
- * @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
 
 
 
 
 
168
  * }
169
  * @return string The HTML of the form field.
170
  */
@@ -173,22 +186,58 @@ function wpmem_form_field( $args ) {
173
  return $wpmem->forms->create_form_field( $args );
174
  }
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  /**
177
  * Wrapper to get form fields.
178
  *
179
  * @since 3.1.1
180
  * @since 3.1.5 Checks if fields array is set or empty before returning.
 
181
  *
182
  * @global object $wpmem The WP_Members object.
 
183
  * @param string $form The form being generated.
184
  * @return array $fields The form fields.
185
  */
186
- function wpmem_fields( $form = 'default' ) {
187
  global $wpmem;
 
188
  if ( ! isset( $wpmem->fields ) || empty( $wpmem->fields ) ) {
189
  $wpmem->load_fields( $form );
190
  }
191
- return $wpmem->fields;
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
 
194
  /**
@@ -331,16 +380,21 @@ function wpmem_get( $tag, $default = '', $type = 'post' ) {
331
  * Compares wpmem_reg_page value with the register page URL.
332
  *
333
  * @since 3.1.4
 
334
  *
335
  * @param string|int $check_page
336
  * @return bool
337
  */
338
- function wpmem_is_reg_page( $check ) {
339
- if ( ! is_int( $check ) ) {
340
- global $wpdb;
341
- $sql = "SELECT ID FROM $wpdb->posts WHERE post_name = '$check' AND post_status = 'publish' LIMIT 1";
342
- $arr = $wpdb->get_results( $sql, ARRAY_A );
343
- $check = $arr[0]['ID'];
 
 
 
 
344
  }
345
  $reg_page = wpmem_get( 'wpmem_reg_page' );
346
  $check_page = get_permalink( $check );
@@ -417,4 +471,29 @@ function wpmem_array_insert( array $array, array $new, $key, $loc = 'after' ) {
417
  return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
418
  }
419
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  // End of file.
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at http://rocketgeek.com
7
+ * Copyright (c) 2006-2017 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
+ * @copyright 2006-2017
14
  *
15
  * Functions included:
16
  * - wpmem_redirect_to_login
19
  * - wpmem_register_url
20
  * - wpmem_profile_url
21
  * - wpmem_current_url
22
+ * - wpmem_form_field
23
+ * - wpmem_form_label
24
  * - wpmem_fields
25
  * - wpmem_gettext
26
  * - wpmem_use_custom_dialog
32
  * - wpmem_load_dropins
33
  * - wpmem_loginout
34
  * - wpmem_array_insert
35
+ * - wpmem_is_user_activated
36
+ * - wpmem_current_post_id
37
  */
38
 
39
  /**
145
  * Returns the current full url.
146
  *
147
  * @since 3.1.1
148
+ * @since 3.1.7 Added check for query string.
149
  *
150
  * @global object $wp
151
  * @param boolean $slash Trailing slash the end of the url (default:true).
152
+ * @param boolean $getq Toggles getting the query string (default:true).
153
  * @return string $url The current page full url path.
154
  */
155
+ function wpmem_current_url( $slash = true, $getq = true ) {
156
  global $wp;
157
  $url = home_url( add_query_arg( array(), $wp->request ) );
158
+ $url = ( $slash ) ? trailingslashit( $url ) : $url;
159
+ $url = ( $getq && count( $_GET ) > 0 ) ? $url . '?' . $_SERVER['QUERY_STRING'] : $url;
160
+ return $url;
161
  }
162
 
163
  /**
166
  * @since 3.1.2
167
  *
168
  * @param array $args {
169
+ * @type string $name (required) The field meta key.
170
+ * @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
171
+ * @type string $value (required) The field's value (can be a null value).
172
+ * @type string $compare (required) Compare value.
173
+ * @type string $class (optional) Class identifier for the field.
174
+ * @type boolean $required (optional) If a value is required default: true).
175
+ * @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
176
+ * @type string $placeholder (optional) Defines the placeholder attribute.
177
+ * @type string $pattern (optional) Adds a regex pattern to the field (HTML5).
178
+ * @type string $title (optional) Defines the title attribute.
179
+ * @type string $min (optional) Adds a min attribute (HTML5).
180
+ * @type string $max (optional) Adds a max attribute (HTML5).
181
  * }
182
  * @return string The HTML of the form field.
183
  */
186
  return $wpmem->forms->create_form_field( $args );
187
  }
188
 
189
+ /**
190
+ * Wrapper for $wpmem->create_form_label().
191
+ *
192
+ * @since 3.1.7
193
+ *
194
+ * @global object $wpmem
195
+ * @param array $args {
196
+ * @type string $meta_key
197
+ * @type string $label_text
198
+ * @type string $type
199
+ * @type string $class (optional)
200
+ * @type string $required (optional)
201
+ * @type string $req_mark (optional)
202
+ * }
203
+ * @return string The HTML of the form label.
204
+ */
205
+ function wpmem_form_label( $args ) {
206
+ global $wpmem;
207
+ return $wpmem->forms->create_form_label( $args );
208
+ }
209
+
210
  /**
211
  * Wrapper to get form fields.
212
  *
213
  * @since 3.1.1
214
  * @since 3.1.5 Checks if fields array is set or empty before returning.
215
+ * @since 3.1.7 Added wpmem_form_fields filter.
216
  *
217
  * @global object $wpmem The WP_Members object.
218
+ * @param string $tag The action being used (default: null).
219
  * @param string $form The form being generated.
220
  * @return array $fields The form fields.
221
  */
222
+ function wpmem_fields( $tag = '', $form = 'default' ) {
223
  global $wpmem;
224
+ // Load fields if none are loaded.
225
  if ( ! isset( $wpmem->fields ) || empty( $wpmem->fields ) ) {
226
  $wpmem->load_fields( $form );
227
  }
228
+
229
+ // @todo Convert tag.
230
+ $tag = wpmem_convert_tag( $tag );
231
+
232
+ /**
233
+ * Filters the fields array.
234
+ *
235
+ * @since 3.1.7
236
+ *
237
+ * @param array $wpmem->fields
238
+ * @param string $tag (optional)
239
+ */
240
+ return apply_filters( 'wpmem_fields', $wpmem->fields, $tag );
241
  }
242
 
243
  /**
380
  * Compares wpmem_reg_page value with the register page URL.
381
  *
382
  * @since 3.1.4
383
+ * @since 3.1.7 Added default of current page ID.
384
  *
385
  * @param string|int $check_page
386
  * @return bool
387
  */
388
+ function wpmem_is_reg_page( $check = false ) {
389
+ if ( ! $check ) {
390
+ $check = get_the_ID();
391
+ } else {
392
+ if ( ! is_int( $check ) ) {
393
+ global $wpdb;
394
+ $sql = "SELECT ID FROM $wpdb->posts WHERE post_name = '$check' AND post_status = 'publish' LIMIT 1";
395
+ $arr = $wpdb->get_results( $sql, ARRAY_A );
396
+ $check = $arr[0]['ID'];
397
+ }
398
  }
399
  $reg_page = wpmem_get( 'wpmem_reg_page' );
400
  $check_page = get_permalink( $check );
471
  return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
472
  }
473
 
474
+ /**
475
+ * Checks if a user is activated.
476
+ *
477
+ * @since 3.1.7
478
+ *
479
+ * @param int $user_id
480
+ * @return bool
481
+ */
482
+ function wpmem_is_user_activated( $user_id = false ) {
483
+ $user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
484
+ $active = get_user_meta( $user_id, 'active', true );
485
+ return ( $active != 1 ) ? false : true;
486
+ }
487
+
488
+ /**
489
+ * Gets post ID of current URL.
490
+ *
491
+ * @since 3.1.7
492
+ *
493
+ * @return int Post ID.
494
+ */
495
+ function wpmem_current_post_id() {
496
+ return url_to_postid( wpmem_current_url() );
497
+ }
498
+
499
  // End of file.
inc/class-wp-members-api.php CHANGED
@@ -1,162 +1,175 @@
1
- <?php
2
- /**
3
- * The WP_Members API Class.
4
- *
5
- * @package WP-Members
6
- * @subpackage WP_Members API Object Class
7
- * @since 3.1.1
8
- */
9
-
10
- class WP_Members_API {
11
-
12
- /**
13
- * Plugin initialization function.
14
- *
15
- * @since 3.1.1
16
- */
17
- function __construct() {
18
-
19
- }
20
-
21
- /**
22
- * Get field keys by meta.
23
- *
24
- * @since 3.1.1
25
- *
26
- * @return array $field_keys
27
- */
28
- function get_field_keys_by_meta() {
29
- global $wpmem;
30
- $field_keys = array();
31
- foreach ( wpmem_fields() as $key => $field ) {
32
- $field_keys[ $field[2] ] = $key;
33
- }
34
- return $field_keys;
35
- }
36
-
37
- /**
38
- * Get select field display values.
39
- *
40
- * @since 3.1.1
41
- *
42
- * @param string $meta_key The field's meta key.
43
- * @return array $display_values {
44
- * The field's display values in an array.
45
- * Elements are stored_value => display value
46
- *
47
- * @type string The display value.
48
- * }
49
- */
50
- function get_select_display_values( $meta_key ) {
51
- global $wpmem;
52
- $keys = $this->get_field_keys_by_meta();
53
- $fields = wpmem_fields();
54
- $raw = $fields[ $keys[ $meta_key ] ][7];
55
- $delimiter = ( isset( $fields[ $keys[ $meta_key ][8] ] ) ) ? $fields[ $keys[ $meta_key ][8] ] : '|';
56
- $display_values = array();
57
- foreach ( $raw as $value ) {
58
- $pieces = explode( $delimiter, trim( $value ) );
59
- if ( $pieces[1] != '' ) {
60
- $display_values[ $pieces[1] ] = $pieces[0];
61
- }
62
- }
63
- return $display_values;
64
- }
65
-
66
- /**
67
- * Checks that a given user field value is unique.
68
- *
69
- * @since 3.1.1
70
- *
71
- * @param string $key The field being checked.
72
- * @param string $val The value to check.
73
- * @return bool True if value if is unique.
74
- */
75
- function is_user_value_unique( $key, $val ) {
76
-
77
- $fields = array( 'ID','user_login','user_pass','user_nicename','user_email','user_url','user_registered','user_activation_key','user_status','display_name' );
78
- // Do we need a meta query or not?
79
- $is_meta = ( ! in_array( $key, $fields ) ) ? true : false;
80
-
81
- if ( $is_meta ) {
82
- $args = array( 'meta_query' => array( array(
83
- 'key' => $key,
84
- 'value' => $val,
85
- 'compare' => '=',
86
- ) ) );
87
- } else {
88
- $args = array( 'search' => $val, 'fields' => 'ID' );
89
- }
90
-
91
- $users = get_users( $args );
92
-
93
- // If there is data in $users, the value is not unique.
94
- return ( $users ) ? false : true;
95
- }
96
-
97
- /**
98
- * Checks counter for next available number and updates the counter.
99
- *
100
- * @since 3.1.1
101
- *
102
- * @param string $option Option name for the counter setting.
103
- * @param int $start Number to start with (optional, default 0).
104
- * @param int $increment Number to increment by (optional, default 1).
105
- * @return int $number Next number in the series.
106
- */
107
- function get_incremental_number( $option, $start = 0, $increment = 1 ) {
108
-
109
- // Get current number from settings
110
- $number = get_option( $option );
111
-
112
- // If there is no number, start with $start.
113
- if ( ! $number ) {
114
- $number = ( $start <= 0 ) ? $start : $start - $increment;
115
- }
116
-
117
- // Increment the number and save the setting.
118
- $number = $number + $increment;
119
- update_option( $option, $number );
120
-
121
- // Return the number.
122
- return $number;
123
- }
124
-
125
- /**
126
- * Generates a unique membership number based on settings.
127
- *
128
- * @since 3.1.1
129
- *
130
- * @param array $args {
131
- * @type string $option
132
- * @type string $meta_key
133
- * @type int $start (optional, default 0)
134
- * @type int $increment (optional, default 1)
135
- * @type int $lead
136
- * }
137
- * @return string $mem_number
138
- */
139
- function generate_membership_number( $args ) {
140
- $defaults = array(
141
- 'start' => 0,
142
- 'increment' => 1,
143
- 'digits' => 8,
144
- 'pad' => true,
145
- );
146
- $args = wp_parse_args( $args, $defaults );
147
- do {
148
- // Generate the appropriate next number
149
- $number = $this->get_incremental_number( $args['option'], $args['start'], $args['increment'] );
150
-
151
- // Cast as string, not integer.
152
- $mem_number = (string)$number;
153
-
154
- // Add leading zeros if less than three digits.
155
- if ( strlen( $mem_number ) < $args['digits'] ) {
156
- $mem_number = ( $args['pad'] ) ? str_pad( $mem_number, $args['digits'], '0', STR_PAD_LEFT ) : $mem_number;
157
- }
158
- } while ( true !== $this->is_user_value_unique( $args['meta_key'], $mem_number ) );
159
- return $mem_number;
160
- }
161
-
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  } // End of WP_Members_Utilties class.
1
+ <?php
2
+ /**
3
+ * The WP_Members API Class.
4
+ *
5
+ * @package WP-Members
6
+ * @subpackage WP_Members API Object Class
7
+ * @since 3.1.1
8
+ */
9
+
10
+ class WP_Members_API {
11
+
12
+ /**
13
+ * Plugin initialization function.
14
+ *
15
+ * @since 3.1.1
16
+ */
17
+ function __construct() {
18
+
19
+ }
20
+
21
+ /**
22
+ * Get field keys by meta.
23
+ *
24
+ * @since 3.1.1
25
+ *
26
+ * @return array $field_keys
27
+ */
28
+ function get_field_keys_by_meta() {
29
+ global $wpmem;
30
+ $field_keys = array();
31
+ foreach ( wpmem_fields() as $key => $field ) {
32
+ $field_keys[ $field[2] ] = $key;
33
+ }
34
+ return $field_keys;
35
+ }
36
+
37
+ /**
38
+ * Get select field display values.
39
+ *
40
+ * @since 3.1.1
41
+ *
42
+ * @param string $meta_key The field's meta key.
43
+ * @return array $display_values {
44
+ * The field's display values in an array.
45
+ * Elements are stored_value => display value
46
+ *
47
+ * @type string The display value.
48
+ * }
49
+ */
50
+ function get_select_display_values( $meta_key ) {
51
+ global $wpmem;
52
+ $keys = $this->get_field_keys_by_meta();
53
+ $fields = wpmem_fields();
54
+ $raw = $fields[ $keys[ $meta_key ] ][7];
55
+ $delimiter = ( isset( $fields[ $keys[ $meta_key ][8] ] ) ) ? $fields[ $keys[ $meta_key ][8] ] : '|';
56
+ $display_values = array();
57
+ foreach ( $raw as $value ) {
58
+ $pieces = explode( $delimiter, trim( $value ) );
59
+ if ( $pieces[1] != '' ) {
60
+ $display_values[ $pieces[1] ] = $pieces[0];
61
+ }
62
+ }
63
+ return $display_values;
64
+ }
65
+
66
+ /**
67
+ * Checks that a given user field value is unique.
68
+ *
69
+ * @since 3.1.1
70
+ *
71
+ * @param string $key The field being checked.
72
+ * @param string $val The value to check.
73
+ * @return bool True if value if is unique.
74
+ */
75
+ function is_user_value_unique( $key, $val ) {
76
+
77
+ $fields = array( 'ID','user_login','user_pass','user_nicename','user_email','user_url','user_registered','user_activation_key','user_status','display_name' );
78
+ // Do we need a meta query or not?
79
+ $is_meta = ( ! in_array( $key, $fields ) ) ? true : false;
80
+
81
+ if ( $is_meta ) {
82
+ $args = array( 'meta_query' => array( array(
83
+ 'key' => $key,
84
+ 'value' => $val,
85
+ 'compare' => '=',
86
+ ) ) );
87
+ } else {
88
+ $args = array( 'search' => $val, 'fields' => 'ID' );
89
+ }
90
+
91
+ $users = get_users( $args );
92
+
93
+ // If there is data in $users, the value is not unique.
94
+ return ( $users ) ? false : true;
95
+ }
96
+
97
+ /**
98
+ * Checks counter for next available number and updates the counter.
99
+ *
100
+ * @since 3.1.1
101
+ *
102
+ * @param string $option Option name for the counter setting.
103
+ * @param int $start Number to start with (optional, default 0).
104
+ * @param int $increment Number to increment by (optional, default 1).
105
+ * @return int $number Next number in the series.
106
+ */
107
+ function get_incremental_number( $option, $start = 0, $increment = 1 ) {
108
+
109
+ // Get current number from settings
110
+ $number = get_option( $option );
111
+
112
+ // If there is no number, start with $start.
113
+ if ( ! $number ) {
114
+ $number = ( $start <= 0 ) ? $start : $start - $increment;
115
+ }
116
+
117
+ // Increment the number and save the setting.
118
+ $number = $number + $increment;
119
+ update_option( $option, $number );
120
+
121
+ // Return the number.
122
+ return $number;
123
+ }
124
+
125
+ /**
126
+ * Generates a unique membership number based on settings.
127
+ *
128
+ * @since 3.1.1
129
+ *
130
+ * @param array $args {
131
+ * @type string $option
132
+ * @type string $meta_key
133
+ * @type int $start (optional, default 0)
134
+ * @type int $increment (optional, default 1)
135
+ * @type int $lead
136
+ * }
137
+ * @return string $mem_number
138
+ */
139
+ function generate_membership_number( $args ) {
140
+ $defaults = array(
141
+ 'start' => 0,
142
+ 'increment' => 1,
143
+ 'digits' => 8,
144
+ 'pad' => true,
145
+ );
146
+ $args = wp_parse_args( $args, $defaults );
147
+ do {
148
+ // Generate the appropriate next number
149
+ $number = $this->get_incremental_number( $args['option'], $args['start'], $args['increment'] );
150
+
151
+ // Cast as string, not integer.
152
+ $mem_number = (string)$number;
153
+
154
+ // Add leading zeros if less than three digits.
155
+ if ( strlen( $mem_number ) < $args['digits'] ) {
156
+ $mem_number = ( $args['pad'] ) ? str_pad( $mem_number, $args['digits'], '0', STR_PAD_LEFT ) : $mem_number;
157
+ }
158
+ } while ( true !== $this->is_user_value_unique( $args['meta_key'], $mem_number ) );
159
+ return $mem_number;
160
+ }
161
+
162
+ /**
163
+ * Checks if a given setting is set and enabled.
164
+ *
165
+ * @since 3.1.7
166
+ *
167
+ * @global object $wpmem
168
+ * @param string $setting
169
+ * @return boolean
170
+ */
171
+ function is_enabled( $setting ) {
172
+ return ( isset( $wpmem->{$setting} ) && $wpmem->{$setting} ) ? true : false;
173
+ }
174
+
175
  } // End of WP_Members_Utilties class.
inc/class-wp-members-forms.php CHANGED
@@ -18,7 +18,6 @@ class WP_Members_Forms {
18
 
19
  }
20
 
21
-
22
  /**
23
  * Creates form fields
24
  *
@@ -28,6 +27,7 @@ class WP_Members_Forms {
28
  * @since 3.1.1 Added $delimiter.
29
  * @since 3.1.2 Changed $valtochk to $compare.
30
  * @since 3.1.6 Added $placeholder.
 
31
  *
32
  * @param array $args {
33
  * @type string $name
@@ -38,6 +38,12 @@ class WP_Members_Forms {
38
  * @type boolean $required
39
  * @type string $delimiter
40
  * @type string $placeholder
 
 
 
 
 
 
41
  * }
42
  * @return string $str The field returned as a string.
43
  */
@@ -46,47 +52,65 @@ class WP_Members_Forms {
46
  $name = $args['name'];
47
  $type = $args['type'];
48
  $value = maybe_unserialize( $args['value'] );
49
- $compare = ( isset( $args['compare'] ) ) ? $args['compare'] : '';
50
- $class = ( isset( $args['class'] ) ) ? $args['class'] : 'textbox';
51
- $required = ( isset( $args['required'] ) ) ? $args['required'] : false;
52
- $delimiter = ( isset( $args['delimiter'] ) ) ? $args['delimiter'] : '|';
53
  $placeholder = ( isset( $args['placeholder'] ) ) ? $args['placeholder'] : false;
 
 
54
 
55
  switch ( $type ) {
56
-
 
57
  case "url":
58
  case "email":
59
- $class = ( $class == 'textbox' ) ? "textbox" : $class;
60
- $value = ( 'url' == $type ) ? esc_url( $value ) : esc_attr( wp_unslash( $value ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  $placeholder = ( $placeholder ) ? ' placeholder="' . $placeholder . '"' : '';
62
- $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" value=\"$value\" class=\"$class\"" . ( ( $required ) ? " required " : "" ) . "$placeholder />";
63
  break;
64
 
65
  case "image":
66
  case "file":
67
- $class = ( $class == 'textbox' ) ? "file" : $class;
68
  $str = "<input name=\"$name\" type=\"file\" id=\"$name\" value=\"$value\" class=\"$class\"" . ( ( $required ) ? " required " : "" ) . " />";
69
  break;
70
 
71
  case "checkbox":
72
- $class = ( $class == 'textbox' ) ? "checkbox" : $class;
73
  $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" value=\"" . esc_attr( $value ) . "\"" . checked( $value, $compare, false ) . ( ( $required ) ? " required " : "" ) . " />";
74
  break;
75
 
76
- case "text":
77
- $value = stripslashes( esc_attr( $value ) );
78
- $placeholder = ( $placeholder ) ? ' placeholder="' . $placeholder . '"' : '';
79
- $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" value=\"$value\" class=\"$class\"" . ( ( $required ) ? " required " : "" ) . "$placeholder />";
80
- break;
81
-
82
  case "textarea":
83
  $value = stripslashes( esc_textarea( $value ) );
84
- $class = ( $class == 'textbox' ) ? "textarea" : $class;
85
- $str = "<textarea cols=\"20\" rows=\"5\" name=\"$name\" id=\"$name\" class=\"$class\"" . ( ( $required ) ? " required " : "" ) . ">$value</textarea>";
86
- break;
87
-
88
- case "password":
89
- $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" class=\"$class\"" . ( ( $required ) ? " required " : "" ) . " />";
90
  break;
91
 
92
  case "hidden":
@@ -123,7 +147,7 @@ class WP_Members_Forms {
123
  break;
124
 
125
  case "multicheckbox":
126
- $class = ( $class == 'textbox' ) ? "checkbox" : $class;
127
  $str = '';
128
  foreach ( $value as $option ) {
129
  $pieces = explode( '|', $option );
@@ -139,7 +163,7 @@ class WP_Members_Forms {
139
  break;
140
 
141
  case "radio":
142
- $class = ( $class == 'textbox' ) ? "radio" : $class;
143
  $str = '';
144
  $num = 1;
145
  foreach ( $value as $option ) {
@@ -155,6 +179,43 @@ class WP_Members_Forms {
155
  return $str;
156
  } // End create_form_field()
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
  /**
160
  * Uploads file from the user.
@@ -250,5 +311,829 @@ class WP_Members_Forms {
250
 
251
  return $param;
252
  }
253
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  } // End of WP_Members_Forms class.
18
 
19
  }
20
 
 
21
  /**
22
  * Creates form fields
23
  *
27
  * @since 3.1.1 Added $delimiter.
28
  * @since 3.1.2 Changed $valtochk to $compare.
29
  * @since 3.1.6 Added $placeholder.
30
+ * @since 3.1.7 Added number type & $min, $max, $title and $pattern attributes.
31
  *
32
  * @param array $args {
33
  * @type string $name
38
  * @type boolean $required
39
  * @type string $delimiter
40
  * @type string $placeholder
41
+ * @type string $pattern
42
+ * @type string $title
43
+ * @type string $min
44
+ * @type string $max
45
+ * @type string $rows Number of rows for a textarea (default:5).
46
+ * @type string $cols Number of columns for a textarea (default:20).
47
  * }
48
  * @return string $str The field returned as a string.
49
  */
52
  $name = $args['name'];
53
  $type = $args['type'];
54
  $value = maybe_unserialize( $args['value'] );
55
+ $compare = ( isset( $args['compare'] ) ) ? $args['compare'] : '';
56
+ $class = ( isset( $args['class'] ) ) ? $args['class'] : 'textbox';
57
+ $required = ( isset( $args['required'] ) ) ? $args['required'] : false;
58
+ $delimiter = ( isset( $args['delimiter'] ) ) ? $args['delimiter'] : '|';
59
  $placeholder = ( isset( $args['placeholder'] ) ) ? $args['placeholder'] : false;
60
+ $pattern = ( isset( $args['pattern'] ) ) ? $args['pattern'] : false;
61
+ $title = ( isset( $args['title'] ) ) ? $args['title'] : false;
62
 
63
  switch ( $type ) {
64
+
65
+ case "text":
66
  case "url":
67
  case "email":
68
+ case "number":
69
+ $class = ( 'textbox' == $class ) ? "textbox" : $class;
70
+ switch ( $type ) {
71
+ case 'url':
72
+ $value = esc_url( $value );
73
+ break;
74
+ case 'email':
75
+ $value = esc_attr( wp_unslash( $value ) );
76
+ break;
77
+ case 'number':
78
+ $value = $value;
79
+ default:
80
+ $value = stripslashes( esc_attr( $value ) );
81
+ break;
82
+ }
83
+ $required = ( $required ) ? ' required' : '';
84
+ $placeholder = ( $placeholder ) ? ' placeholder="' . $placeholder . '"' : '';
85
+ $pattern = ( $pattern ) ? ' pattern="' . $pattern . '"' : '';
86
+ $title = ( $title ) ? ' title="' . $title . '"' : '';
87
+ $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : '';
88
+ $max = ( isset( $args['max'] ) ) ? ' max="' . $args['max'] . '"' : '';
89
+ $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" value=\"$value\" class=\"$class\"$placeholder$title$pattern$min$max" . ( ( $required ) ? " required " : "" ) . " />";
90
+ break;
91
+
92
+ case "password":
93
  $placeholder = ( $placeholder ) ? ' placeholder="' . $placeholder . '"' : '';
94
+ $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" class=\"$class\"$placeholder" . ( ( $required ) ? " required " : "" ) . " />";
95
  break;
96
 
97
  case "image":
98
  case "file":
99
+ $class = ( 'textbox' == $class ) ? "file" : $class;
100
  $str = "<input name=\"$name\" type=\"file\" id=\"$name\" value=\"$value\" class=\"$class\"" . ( ( $required ) ? " required " : "" ) . " />";
101
  break;
102
 
103
  case "checkbox":
104
+ $class = ( 'textbox' == $class ) ? "checkbox" : $class;
105
  $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" value=\"" . esc_attr( $value ) . "\"" . checked( $value, $compare, false ) . ( ( $required ) ? " required " : "" ) . " />";
106
  break;
107
 
 
 
 
 
 
 
108
  case "textarea":
109
  $value = stripslashes( esc_textarea( $value ) );
110
+ $class = ( 'textbox' == $class ) ? "textarea" : $class;
111
+ $rows = ( isset( $args['rows'] ) ) ? $args['rows'] : '5';
112
+ $cols = ( isset( $args['cols'] ) ) ? $args['cols'] : '20';
113
+ $str = "<textarea cols=\"$cols\" rows=\"$rows\" name=\"$name\" id=\"$name\" class=\"$class\"" . ( ( $required ) ? " required " : "" ) . ">$value</textarea>";
 
 
114
  break;
115
 
116
  case "hidden":
147
  break;
148
 
149
  case "multicheckbox":
150
+ $class = ( 'textbox' == $class ) ? "checkbox" : $class;
151
  $str = '';
152
  foreach ( $value as $option ) {
153
  $pieces = explode( '|', $option );
163
  break;
164
 
165
  case "radio":
166
+ $class = ( 'textbox' == $class ) ? "radio" : $class;
167
  $str = '';
168
  $num = 1;
169
  foreach ( $value as $option ) {
179
  return $str;
180
  } // End create_form_field()
181
 
182
+ /**
183
+ * Create form label.
184
+ *
185
+ * @since 3.1.7
186
+ *
187
+ * @param array $args {
188
+ * @type string $meta_key
189
+ * @type string $label_text
190
+ * @type string $type
191
+ * @type string $class (optional)
192
+ * @type string $required (optional)
193
+ * @type string $req_mark (optional)
194
+ * }
195
+ * @return string $label
196
+ */
197
+ function create_form_label( $args ) {
198
+ global $wpmem;
199
+
200
+ $meta_key = $args['meta_key'];
201
+ $label = $args['label'];
202
+ $type = $args['type'];
203
+ $class = ( isset( $args['class'] ) ) ? $args['class'] : false;
204
+ $required = ( isset( $args['required'] ) ) ? $args['required'] : false;
205
+ $req_mark = ( isset( $args['req_mark'] ) ) ? $args['req_mark'] : false;
206
+
207
+ //$req_mark = ( ! $req_mark ) ? $wpmem->get_text( 'register_req_mark' ) : '*';
208
+
209
+ if ( ! $class ) {
210
+ $class = ( $type == 'password' || $type == 'email' || $type == 'url' ) ? 'text' : $type;
211
+ }
212
+
213
+ $label = '<label for="' . $meta_key . '" class="' . $class . '">' . __( $label, 'wp-members' );
214
+ $label = ( $required ) ? $label . $req_mark : $label;
215
+ $label = $label . '</label>';
216
+
217
+ return $label;
218
+ }
219
 
220
  /**
221
  * Uploads file from the user.
311
 
312
  return $param;
313
  }
314
+
315
+ /**
316
+ * Login Form Dialog.
317
+ *
318
+ * Builds the form used for login, change password, and reset password.
319
+ *
320
+ * @since 2.5.1
321
+ * @since 3.1.7 Added WP action login_form.
322
+ *
323
+ * @param string $page
324
+ * @param array $arr {
325
+ * The elements needed to generate the form (login|reset password|forgotten password).
326
+ *
327
+ * @type string $heading Form heading text.
328
+ * @type string $action The form action (login|pwdchange|pwdreset).
329
+ * @type string $button_text Form submit button text.
330
+ * @type array $inputs {
331
+ * The form input values.
332
+ *
333
+ * @type array {
334
+ *
335
+ * @type string $name The field label.
336
+ * @type string $type Input type.
337
+ * @type string $tag Input tag name.
338
+ * @type string $class Input tag class.
339
+ * @type string $div Div wrapper class.
340
+ * }
341
+ * }
342
+ * @type string $redirect_to Optional. URL to redirect to.
343
+ * }
344
+ * @return string $form The HTML for the form as a string.
345
+ */
346
+ function login_form( $page, $arr ) {
347
+
348
+ global $wpmem;
349
+
350
+ // set up default wrappers
351
+ $defaults = array(
352
+
353
+ // wrappers
354
+ 'heading_before' => '<legend>',
355
+ 'heading_after' => '</legend>',
356
+ 'fieldset_before' => '<fieldset>',
357
+ 'fieldset_after' => '</fieldset>',
358
+ 'main_div_before' => '<div id="wpmem_login">',
359
+ 'main_div_after' => '</div>',
360
+ 'txt_before' => '',
361
+ 'txt_after' => '',
362
+ 'row_before' => '',
363
+ 'row_after' => '',
364
+ 'buttons_before' => '<div class="button_div">',
365
+ 'buttons_after' => '</div>',
366
+ 'link_before' => '<div align="right" class="link-text">',
367
+ 'link_after' => '</div>',
368
+
369
+ // classes & ids
370
+ 'form_id' => '',
371
+ 'form_class' => 'form',
372
+ 'button_id' => '',
373
+ 'button_class' => 'buttons',
374
+
375
+ // other
376
+ 'strip_breaks' => true,
377
+ 'wrap_inputs' => true,
378
+ 'remember_check' => true,
379
+ 'n' => "\n",
380
+ 't' => "\t",
381
+ 'redirect_to' => ( isset( $_REQUEST['redirect_to'] ) ) ? esc_url( $_REQUEST['redirect_to'] ) : ( ( isset( $arr['redirect_to'] ) ) ? $arr['redirect_to'] : get_permalink() ),
382
+ 'login_form_action' => true,
383
+
384
+ );
385
+
386
+ /**
387
+ * Filter the default form arguments.
388
+ *
389
+ * This filter accepts an array of various elements to replace the form defaults. This
390
+ * includes default tags, labels, text, and small items including various booleans.
391
+ *
392
+ * @since 2.9.0
393
+ *
394
+ * @param array An array of arguments to merge with defaults. Default null.
395
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
396
+ */
397
+ $args = apply_filters( 'wpmem_login_form_args', '', $arr['action'] );
398
+
399
+ // Merge $args with defaults.
400
+ $args = wp_parse_args( $args, $defaults );
401
+
402
+ // Build the input rows.
403
+ foreach ( $arr['inputs'] as $input ) {
404
+ $label = '<label for="' . $input['tag'] . '">' . $input['name'] . '</label>';
405
+ $field = wpmem_create_formfield( $input['tag'], $input['type'], '', '', $input['class'] );
406
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="' . $input['div'] . '">' : '';
407
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
408
+ $rows[] = array(
409
+ 'row_before' => $args['row_before'],
410
+ 'label' => $label,
411
+ 'field_before' => $field_before,
412
+ 'field' => $field,
413
+ 'field_after' => $field_after,
414
+ 'row_after' => $args['row_after'],
415
+ );
416
+ }
417
+
418
+ /**
419
+ * Filter the array of form rows.
420
+ *
421
+ * This filter receives an array of the main rows in the form, each array element being
422
+ * an array of that particular row's pieces. This allows making changes to individual
423
+ * parts of a row without needing to parse through a string of HTML.
424
+ *
425
+ * @since 2.9.0
426
+ *
427
+ * @param array $rows An array containing the form rows.
428
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
429
+ */
430
+ $rows = apply_filters( 'wpmem_login_form_rows', $rows, $arr['action'] );
431
+
432
+ // Put the rows from the array into $form.
433
+ $form = '';
434
+ foreach ( $rows as $row_item ) {
435
+ $row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
436
+ $row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
437
+ $row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
438
+ $form.= $row;
439
+ }
440
+
441
+ // Handle outside elements added to the login form (currently ONLY for login).
442
+ if ( 'login' == $arr['action'] && $args['login_form_action'] ) {
443
+ ob_start();
444
+ /** This action is documented in wp-login.php */
445
+ do_action( 'login_form' );
446
+ $add_to_form = ob_get_contents();
447
+ ob_end_clean();
448
+ $form.= $add_to_form;
449
+ }
450
+
451
+ // Build hidden fields, filter, and add to the form.
452
+ $hidden = wpmem_create_formfield( 'redirect_to', 'hidden', $args['redirect_to'] ) . $args['n'];
453
+ $hidden = $hidden . wpmem_create_formfield( 'a', 'hidden', $arr['action'] ) . $args['n'];
454
+ $hidden = ( $arr['action'] != 'login' ) ? $hidden . wpmem_create_formfield( 'formsubmit', 'hidden', '1' ) : $hidden;
455
+
456
+ /**
457
+ * Filter the hidden field HTML.
458
+ *
459
+ * @since 2.9.0
460
+ *
461
+ * @param string $hidden The generated HTML of hidden fields.
462
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
463
+ */
464
+ $form = $form . apply_filters( 'wpmem_login_hidden_fields', $hidden, $arr['action'] );
465
+
466
+ // Build the buttons, filter, and add to the form.
467
+ if ( $arr['action'] == 'login' ) {
468
+ $args['remember_check'] = ( $args['remember_check'] ) ? $args['t'] . wpmem_create_formfield( 'rememberme', 'checkbox', 'forever' ) . '&nbsp;' . '<label for="rememberme">' . $wpmem->get_text( 'remember_me' ) . '</label>&nbsp;&nbsp;' . $args['n'] : '';
469
+ $buttons = $args['remember_check'] . $args['t'] . '<input type="submit" name="Submit" value="' . $arr['button_text'] . '" class="' . $args['button_class'] . '" />' . $args['n'];
470
+ } else {
471
+ $buttons = '<input type="submit" name="Submit" value="' . $arr['button_text'] . '" class="' . $args['button_class'] . '" />' . $args['n'];
472
+ }
473
+
474
+ /**
475
+ * Filter the HTML for form buttons.
476
+ *
477
+ * The string includes the buttons, as well as the before/after wrapper elements.
478
+ *
479
+ * @since 2.9.0
480
+ *
481
+ * @param string $buttons The generated HTML of the form buttons.
482
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
483
+ */
484
+ $form = $form . apply_filters( 'wpmem_login_form_buttons', $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'], $arr['action'] );
485
+
486
+ $links_array = array(
487
+ 'forgot' => array(
488
+ 'link' => add_query_arg( 'a', 'pwdreset', $wpmem->user_pages['profile'] ),
489
+ 'page' => 'profile',
490
+ 'action' => 'login',
491
+ ),
492
+ 'register' => array(
493
+ 'link' => $wpmem->user_pages['register'],
494
+ 'page' => 'register',
495
+ 'action' => 'login',
496
+ ),
497
+ 'username' => array(
498
+ 'link' => add_query_arg( 'a', 'getusername', $wpmem->user_pages['profile'] ),
499
+ 'page' => 'profile',
500
+ 'action' => 'pwdreset',
501
+ ),
502
+ );
503
+ foreach ( $links_array as $key => $value ) {
504
+ if ( ( $wpmem->user_pages[ $value['page'] ] || 'members' == $page ) && $value['action'] == $arr['action'] ) {
505
+ /**
506
+ * Filters register, forgot password, and forgot username links.
507
+ *
508
+ * @since 2.8.0
509
+ * @since 3.1.7 Combined all to a single process.
510
+ *
511
+ * @param string The raw link.
512
+ */
513
+ $link = apply_filters( "wpmem_{$key}_link", $value['link'] );
514
+ $str = $wpmem->get_text( "{$key}_link_before" ) . '<a href="' . $link . '">' . $wpmem->get_text( "{$key}_link" ) . '</a>';
515
+ /**
516
+ * Filters the register, forgot password, and forgot username links HTML.
517
+ *
518
+ * @since 2.9.0
519
+ * @since 3.0.9 Added $link parameter.
520
+ * @since 3.1.7 Combined all to a single process.
521
+ *
522
+ * @param string $str The link HTML.
523
+ * @param string $link The link.
524
+ */
525
+ $form = $form . $args['link_before'] . apply_filters( "wpmem_{$key}_link_str", $str, $link ) . $args['link_after'] . $args['n'];
526
+ }
527
+ }
528
+
529
+ // Apply the heading.
530
+ $form = $args['heading_before'] . $arr['heading'] . $args['heading_after'] . $args['n'] . $form;
531
+
532
+ // Apply fieldset wrapper.
533
+ $form = $args['fieldset_before'] . $args['n'] . $form . $args['fieldset_after'] . $args['n'];
534
+
535
+ // Apply form wrapper.
536
+ $form = '<form action="' . get_permalink() . '" method="POST" id="' . $args['form_id'] . '" class="' . $args['form_class'] . '">' . $args['n'] . $form . '</form>';
537
+
538
+ // Apply anchor.
539
+ $form = '<a name="' . $arr['action'] . '"></a>' . $args['n'] . $form;
540
+
541
+ // Apply main wrapper.
542
+ $form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'];
543
+
544
+ // Apply wpmem_txt wrapper.
545
+ $form = $args['txt_before'] . $form . $args['txt_after'];
546
+
547
+ // Remove line breaks.
548
+ $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
549
+
550
+ /**
551
+ * Filter the generated HTML of the entire form.
552
+ *
553
+ * @since 2.7.4
554
+ *
555
+ * @param string $form The HTML of the final generated form.
556
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
557
+ */
558
+ $form = apply_filters( 'wpmem_login_form', $form, $arr['action'] );
559
+
560
+ /**
561
+ * Filter before the form.
562
+ *
563
+ * This rarely used filter allows you to stick any string onto the front of
564
+ * the generated form.
565
+ *
566
+ * @since 2.7.4
567
+ *
568
+ * @param string $str The HTML to add before the form. Default null.
569
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
570
+ */
571
+ $form = apply_filters( 'wpmem_login_form_before', '', $arr['action'] ) . $form;
572
+
573
+ return $form;
574
+ } // End wpmem_login_form.
575
+
576
+ /**
577
+ * Registration Form Dialog.
578
+ *
579
+ * Outputs the form for new user registration and existing user edits.
580
+ *
581
+ * @since 2.5.1
582
+ *
583
+ * @global object $wpmem The WP_Members object.
584
+ * @global string $wpmem_regchk Used to determine if the form is in an error state.
585
+ * @global array $userdata Used to get the user's registration data if they are logged in (user profile edit).
586
+ * @param string $tag (optional) Toggles between new registration ('new') and user profile edit ('edit').
587
+ * @param string $heading (optional) The heading text for the form, null (default) for new registration.
588
+ * @return string $form The HTML for the entire form as a string.
589
+ */
590
+ function register_form( $tag = 'new', $heading = '', $redirect_to = null ) {
591
+
592
+ global $wpmem, $wpmem_regchk, $userdata;
593
+
594
+ // Set up default wrappers.
595
+ $defaults = array(
596
+
597
+ // Wrappers.
598
+ 'heading_before' => '<legend>',
599
+ 'heading_after' => '</legend>',
600
+ 'fieldset_before' => '<fieldset>',
601
+ 'fieldset_after' => '</fieldset>',
602
+ 'main_div_before' => '<div id="wpmem_reg">',
603
+ 'main_div_after' => '</div>',
604
+ 'txt_before' => '',
605
+ 'txt_after' => '',
606
+ 'row_before' => '',
607
+ 'row_after' => '',
608
+ 'buttons_before' => '<div class="button_div">',
609
+ 'buttons_after' => '</div>',
610
+
611
+ // Classes & ids.
612
+ 'form_id' => '',
613
+ 'form_class' => 'form',
614
+ 'button_id' => '',
615
+ 'button_class' => 'buttons',
616
+
617
+ // Required field tags and text.
618
+ 'req_mark' => $wpmem->get_text( 'register_req_mark' ),
619
+ 'req_label' => $wpmem->get_text( 'register_required' ),
620
+ 'req_label_before' => '<div class="req-text">',
621
+ 'req_label_after' => '</div>',
622
+
623
+ // Buttons.
624
+ 'show_clear_form' => false,
625
+ 'clear_form' => $wpmem->get_text( 'register_clear' ),
626
+ 'submit_register' => $wpmem->get_text( 'register_submit' ),
627
+ 'submit_update' => $wpmem->get_text( 'profile_submit' ),
628
+
629
+ // Other.
630
+ 'strip_breaks' => true,
631
+ 'use_nonce' => false,
632
+ 'wrap_inputs' => true,
633
+ 'n' => "\n",
634
+ 't' => "\t",
635
+
636
+ );
637
+
638
+ /**
639
+ * Filter the default form arguments.
640
+ *
641
+ * This filter accepts an array of various elements to replace the form defaults. This
642
+ * includes default tags, labels, text, and small items including various booleans.
643
+ *
644
+ * @since 2.9.0
645
+ *
646
+ * @param array An array of arguments to merge with defaults. Default null.
647
+ * @param string $tag Toggle new registration or profile update. new|edit.
648
+ */
649
+ $args = apply_filters( 'wpmem_register_form_args', '', $tag );
650
+
651
+ // Merge $args with defaults.
652
+ $args = wp_parse_args( $args, $defaults );
653
+
654
+ // Username is editable if new reg, otherwise user profile is not.
655
+ if ( $tag == 'edit' ) {
656
+ // This is the User Profile edit - username is not editable.
657
+ $val = $userdata->user_login;
658
+ $label = '<label for="user_login" class="text">' . $wpmem->get_text( 'profile_username' ) . '</label>';
659
+ $input = '<p class="noinput">' . $val . '</p>';
660
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
661
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
662
+ } else {
663
+ // This is a new registration.
664
+ $val = ( isset( $_POST['user_login'] ) ) ? stripslashes( $_POST['user_login'] ) : '';
665
+ $label = '<label for="user_login" class="text">' . $wpmem->get_text( 'register_username' ) . $args['req_mark'] . '</label>';
666
+ $input = wpmem_form_field( array(
667
+ 'name' => 'user_login',
668
+ 'type' => 'text',
669
+ 'value' => $val,
670
+ 'compare' => '',
671
+ 'required' => true,
672
+ ) );
673
+
674
+ }
675
+
676
+ // Add the username row to the array.
677
+ $rows['username'] = array(
678
+ 'meta' => 'username',
679
+ 'type' => 'text',
680
+ 'value' => $val,
681
+ 'label_text' => $wpmem->get_text( 'register_username' ),
682
+ 'row_before' => $args['row_before'],
683
+ 'label' => $label,
684
+ 'field_before' => ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '',
685
+ 'field' => $input,
686
+ 'field_after' => ( $args['wrap_inputs'] ) ? '</div>': '',
687
+ 'row_after' => $args['row_after'],
688
+ );
689
+
690
+ /**
691
+ * Filter the array of form fields.
692
+ *
693
+ * The form fields are stored in the WP options table as wpmembers_fields. This
694
+ * filter can filter that array after the option is retreived before the fields
695
+ * are parsed. This allows you to change the fields that may be used in the form
696
+ * on the fly.
697
+ *
698
+ * @since 2.9.0
699
+ * @deprecated 3.1.7 Use wpmem_fields instead.
700
+ *
701
+ * @param array The array of form fields.
702
+ * @param string $tag Toggle new registration or profile update. new|edit.
703
+ */
704
+ $wpmem_fields = apply_filters( 'wpmem_register_fields_arr', wpmem_fields( $tag ), $tag );
705
+
706
+ $hidden = '';
707
+
708
+ // Loop through the remaining fields.
709
+ foreach ( $wpmem_fields as $meta_key => $field ) {
710
+
711
+ // Start with a clean row.
712
+ $val = ''; $label = ''; $input = ''; $field_before = ''; $field_after = '';
713
+
714
+ // Skips user selected passwords for profile update.
715
+ $pass_arr = array( 'password', 'confirm_password', 'password_confirm' );
716
+ $do_row = ( $tag == 'edit' && in_array( $meta_key, $pass_arr ) ) ? false : true;
717
+
718
+ // Skips tos, makes tos field hidden on user edit page, unless they haven't got a value for tos.
719
+ if ( $meta_key == 'tos' && $tag == 'edit' && ( get_user_meta( $userdata->ID, 'tos', true ) ) ) {
720
+ $do_row = false;
721
+ $hidden_tos = wpmem_form_field( array(
722
+ 'name' => $meta_key,
723
+ 'type' => 'hidden',
724
+ 'value' => get_user_meta( $userdata->ID, 'tos', true )
725
+ ) );
726
+ }
727
+
728
+ // Handle hidden fields
729
+ if ( 'hidden' == $field['type'] ) {
730
+ $do_row = false;
731
+ $hidden.= wpmem_form_field( array(
732
+ 'name' => $meta_key,
733
+ 'type' => $field['type'],
734
+ 'value' => $field['value'],
735
+ 'compare' => $valtochk,
736
+ //'class' => ( $class ) ? $class : 'textbox',
737
+ 'required' => $field['required'],
738
+ ) );
739
+ }
740
+
741
+ // If the field is set to display and we aren't skipping, construct the row.
742
+ if ( $do_row && $field['register'] ) {
743
+
744
+ // Label for all but TOS.
745
+ if ( $meta_key != 'tos' ) {
746
+
747
+ $class = ( $field['type'] == 'password' || $field['type'] == 'email' || $field['type'] == 'url' ) ? 'text' : $field['type'];
748
+
749
+ // $label = '<label for="' . $meta_key . '" class="' . $class . '">' . __( $field['label'], 'wp-members' );
750
+ // $label = ( $field['required'] ) ? $label . $args['req_mark'] : $label;
751
+ // $label = $label . '</label>';
752
+
753
+ $label = wpmem_form_label( array(
754
+ 'meta_key' => $meta_key,
755
+ 'label' => __( $field['label'], 'wp-members' ),
756
+ 'type' => $field['type'],
757
+ 'class' => $class,
758
+ 'required' => $field['required'],
759
+ 'req_mark' => $args['req_mark']
760
+ ) );
761
+
762
+ }
763
+
764
+ // Gets the field value for both edit profile and submitted reg w/ error.
765
+ if ( ( $tag == 'edit' ) && ( $wpmem_regchk != 'updaterr' ) ) { // @todo Should this use $wpmem->regchk? This is the last remaining use of $wpmem_regchk in this function.
766
+
767
+ switch ( $meta_key ) {
768
+ case( 'description' ):
769
+ $val = htmlspecialchars( get_user_meta( $userdata->ID, 'description', 'true' ) );
770
+ break;
771
+
772
+ case 'user_email':
773
+ case 'confirm_email':
774
+ $val = sanitize_email( $userdata->user_email );
775
+ break;
776
+
777
+ case 'user_url':
778
+ $val = esc_url( $userdata->user_url );
779
+ break;
780
+
781
+ case 'display_name':
782
+ $val = sanitize_text_field( $userdata->display_name );
783
+ break;
784
+
785
+ default:
786
+ $val = sanitize_text_field( get_user_meta( $userdata->ID, $meta_key, 'true' ) );
787
+ break;
788
+ }
789
+
790
+ } else {
791
+ if ( 'file' == $field['type'] ) {
792
+ $val = ( isset( $_FILES[ $meta_key ]['name'] ) ) ? $_FILES[ $meta_key ]['name'] : '' ;
793
+ } else {
794
+ $val = ( isset( $_POST[ $meta_key ] ) ) ? $_POST[ $meta_key ] : '';
795
+ }
796
+ }
797
+
798
+ // Does the tos field.
799
+ if ( $meta_key == 'tos' ) {
800
+
801
+ $val = ( isset( $_POST[ $meta_key ] ) ) ? $_POST[ $meta_key ] : '';
802
+
803
+ // Should be checked by default? and only if form hasn't been submitted.
804
+ $val = ( ! $_POST && $field['checked_default'] ) ? $field['checked_value'] : $val;
805
+ $input = wpmem_form_field( array(
806
+ 'name' => $meta_key,
807
+ 'type' => $field['type'],
808
+ 'value' => $field['checked_value'],
809
+ 'compare' => $val
810
+ ) );
811
+ $input = ( $field['required'] ) ? $input . $args['req_mark'] : $input;
812
+
813
+ // Determine if TOS is a WP page or not.
814
+ $tos_content = stripslashes( get_option( 'wpmembers_tos' ) );
815
+ if ( has_shortcode( $tos_content, 'wp-members' ) || has_shortcode( $tos_content, 'wpmem_tos' ) ) {
816
+ $link = do_shortcode( $tos_content );
817
+ $tos_pop = '<a href="' . $link . '" target="_blank">';
818
+ } else {
819
+ $tos_pop = "<a href=\"#\" onClick=\"window.open('" . WPMEM_DIR . "/wp-members-tos.php','mywindow');\">";
820
+ }
821
+
822
+ /**
823
+ * Filter the TOS link text.
824
+ *
825
+ * @since 2.7.5
826
+ *
827
+ * @param string The link text.
828
+ * @param string $tag Toggle new registration or profile update. new|edit.
829
+ */
830
+ $input.= apply_filters( 'wpmem_tos_link_txt', sprintf( $wpmem->get_text( 'register_tos' ), $tos_pop, '</a>' ), $tag );
831
+
832
+ // In previous versions, the div class would end up being the same as the row before.
833
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
834
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
835
+
836
+ } else {
837
+
838
+ // For checkboxes.
839
+ if ( $field['type'] == 'checkbox' ) {
840
+ $valtochk = $val;
841
+ $val = $field['checked_value'];
842
+ // if it should it be checked by default (& only if form not submitted), then override above...
843
+ if ( $field['checked_default'] && ( ! $_POST && $tag != 'edit' ) ) { $val = $valtochk = $field['checked_value']; }
844
+ }
845
+
846
+ // For dropdown select.
847
+ if ( $field['type'] == 'select' || $field['type'] == 'radio' || $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) {
848
+ $valtochk = $val;
849
+ $val = $field['values'];
850
+ }
851
+
852
+ if ( ! isset( $valtochk ) ) { $valtochk = ''; }
853
+
854
+ if ( 'edit' == $tag && ( 'file' == $field['type'] || 'image' == $field['type'] ) ) {
855
+
856
+ $attachment_url = wp_get_attachment_url( $val );
857
+ $empty_file = '<span class="description">' . __( 'None' ) . '</span>';
858
+ if ( 'file' == $field['type'] ) {
859
+ $input = ( $attachment_url ) ? '<a href="' . $attachment_url . '">' . get_the_title( $val ) . '</a>' : $empty_file;
860
+ } else {
861
+ $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file;
862
+ }
863
+ // @todo - come up with a way to handle file updates - user profile form does not support multitype
864
+ $input.= '<br />' . $wpmem->get_text( 'profile_upload' ) . '<br />';
865
+ $input.= wpmem_form_field( array(
866
+ 'name' => $meta_key,
867
+ 'type' => $field['type'],
868
+ 'value' => $val,
869
+ 'compare' => $valtochk,
870
+ ) );
871
+
872
+ } else {
873
+
874
+ // For all other input types.
875
+ //$input = wpmem_create_formfield( $meta_key, $field['type'], $val, $valtochk );
876
+ $formfield_args = array(
877
+ 'name' => $meta_key,
878
+ 'type' => $field['type'],
879
+ 'value' => $val,
880
+ 'compare' => $valtochk,
881
+ //'class' => ( $class ) ? $class : 'textbox',
882
+ 'required' => $field['required'],
883
+ 'placeholder' => ( isset( $field['placeholder'] ) ) ? $field['placeholder'] : '',
884
+ 'pattern' => ( isset( $field['pattern'] ) ) ? $field['pattern'] : false,
885
+ 'title' => ( isset( $field['title'] ) ) ? $field['title'] : false,
886
+ 'min' => ( isset( $field['min'] ) ) ? $field['min'] : false,
887
+ 'max' => ( isset( $field['max'] ) ) ? $field['max'] : false,
888
+ );
889
+ if ( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) {
890
+ $formfield_args['delimiter'] = $field['delimiter'];
891
+ }
892
+ $input = wpmem_form_field( $formfield_args );
893
+
894
+ }
895
+
896
+ // Determine input wrappers.
897
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_' . $class . '">' : '';
898
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
899
+ }
900
+
901
+ }
902
+
903
+ // If the row is set to display, add the row to the form array.
904
+ if ( $field['register'] ) {
905
+
906
+ $values = '';
907
+ if ( 'multicheckbox' == $field['type'] || 'select' == $field['type'] || 'multiselect' == $field['type'] || 'radio' == $field['type'] ) {
908
+ $values = $val;
909
+ $val = $valtochk;
910
+ }
911
+
912
+ $rows[ $meta_key ] = array(
913
+ 'meta' => $meta_key,
914
+ 'type' => $field['type'],
915
+ 'value' => $val,
916
+ 'values' => $values,
917
+ 'label_text' => __( $field['label'], 'wp-members' ),
918
+ 'row_before' => $args['row_before'],
919
+ 'label' => $label,
920
+ 'field_before' => $field_before,
921
+ 'field' => $input,
922
+ 'field_after' => $field_after,
923
+ 'row_after' => $args['row_after'],
924
+ );
925
+ }
926
+ }
927
+
928
+ // If captcha is Really Simple CAPTCHA.
929
+ if ( $wpmem->captcha == 2 && $tag != 'edit' ) {
930
+ $row = wpmem_build_rs_captcha();
931
+ $rows['captcha'] = array(
932
+ 'meta' => '',
933
+ 'type' => 'text',
934
+ 'value' => '',
935
+ 'values' => '',
936
+ 'label_text' => $row['label_text'],
937
+ 'row_before' => $args['row_before'],
938
+ 'label' => $row['label'],
939
+ 'field_before' => ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '',
940
+ 'field' => $row['field'],
941
+ 'field_after' => ( $args['wrap_inputs'] ) ? '</div>' : '',
942
+ 'row_after' => $args['row_after'],
943
+ );
944
+ }
945
+
946
+ /**
947
+ * Filter the array of form rows.
948
+ *
949
+ * This filter receives an array of the main rows in the form, each array element being
950
+ * an array of that particular row's pieces. This allows making changes to individual
951
+ * parts of a row without needing to parse through a string of HTML.
952
+ *
953
+ * @since 2.9.0
954
+ * @since 3.0.9 Added $rows['label_text'].
955
+ * @since 3.1.0 Added $rows['key'].
956
+ * @since 3.1.6 Deprecated $rows['order'].
957
+ *
958
+ * @param array $rows {
959
+ * An array containing the form rows.
960
+ *
961
+ * @type string order Field display order. (deprecated as of 3.1.6)
962
+ * @type string meta Field meta tag (not used for display).
963
+ * @type string type Input field type (not used for display).
964
+ * @type string value Input field value (not used for display).
965
+ * @type string values Possible field values (dropdown, multiple select/check, radio).
966
+ * @type string label_text Raw text for the label (not used for display).
967
+ * @type string row_before Opening wrapper tag around the row.
968
+ * @type string label Label tag.
969
+ * @type string field_before Opening wrapper tag before the input tag.
970
+ * @type string field The field input tag.
971
+ * @type string field_after Closing wrapper tag around the input tag.
972
+ * @type string row_after Closing wrapper tag around the row.
973
+ * }
974
+ * @param string $tag Toggle new registration or profile update. new|edit.
975
+ */
976
+ $rows = apply_filters( 'wpmem_register_form_rows', $rows, $tag );
977
+
978
+ // Put the rows from the array into $form.
979
+ $form = ''; $enctype = '';
980
+ foreach ( $rows as $row_item ) {
981
+ $enctype = ( $row_item['type'] == 'file' || $row_item['type'] == 'image' ) ? "multipart/form-data" : $enctype;
982
+ $row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
983
+ $row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
984
+ $row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
985
+ $form.= $row;
986
+ }
987
+
988
+ // Do recaptcha if enabled.
989
+ if ( ( $wpmem->captcha == 1 || $wpmem->captcha == 3 ) && $tag != 'edit' ) { // don't show on edit page!
990
+
991
+ // Get the captcha options.
992
+ $wpmem_captcha = get_option( 'wpmembers_captcha' );
993
+
994
+ // Start with a clean row.
995
+ $row = '';
996
+ $row = '<div class="clear"></div>';
997
+ $row.= '<div align="right" class="captcha">' . wpmem_inc_recaptcha( $wpmem_captcha['recaptcha'] ) . '</div>';
998
+
999
+ // Add the captcha row to the form.
1000
+ /**
1001
+ * Filter the HTML for the CAPTCHA row.
1002
+ *
1003
+ * @since 2.9.0
1004
+ *
1005
+ * @param string The HTML for the entire row (includes HTML tags plus reCAPTCHA).
1006
+ * @param string $tag Toggle new registration or profile update. new|edit.
1007
+ */
1008
+ $form.= apply_filters( 'wpmem_register_captcha_row', $args['row_before'] . $row . $args['row_after'], $tag );
1009
+ }
1010
+
1011
+ // Create hidden fields.
1012
+ $var = ( $tag == 'edit' ) ? 'update' : 'register';
1013
+ $redirect_to = ( isset( $_REQUEST['redirect_to'] ) ) ? esc_url( $_REQUEST['redirect_to'] ) : ( ( $redirect_to ) ? $redirect_to : get_permalink() );
1014
+ $hidden .= '<input name="a" type="hidden" value="' . $var . '" />' . $args['n'];
1015
+ $hidden .= '<input name="wpmem_reg_page" type="hidden" value="' . get_permalink() . '" />' . $args['n'];
1016
+ if ( $redirect_to != get_permalink() ) {
1017
+ $hidden.= '<input name="redirect_to" type="hidden" value="' . $redirect_to . '" />' . $args['n'];
1018
+ }
1019
+ $hidden = ( isset( $hidden_tos ) ) ? $hidden . $hidden_tos . $args['n'] : $hidden;
1020
+
1021
+ /**
1022
+ * Filter the hidden field HTML.
1023
+ *
1024
+ * @since 2.9.0
1025
+ *
1026
+ * @param string $hidden The generated HTML of hidden fields.
1027
+ * @param string $tag Toggle new registration or profile update. new|edit.
1028
+ */
1029
+ $hidden = apply_filters( 'wpmem_register_hidden_fields', $hidden, $tag );
1030
+
1031
+ // Add the hidden fields to the form.
1032
+ $form.= $hidden;
1033
+
1034
+ // Create buttons and wrapper.
1035
+ $button_text = ( $tag == 'edit' ) ? $args['submit_update'] : $args['submit_register'];
1036
+ $buttons = ( $args['show_clear_form'] ) ? '<input name="reset" type="reset" value="' . $args['clear_form'] . '" class="' . $args['button_class'] . '" /> ' . $args['n'] : '';
1037
+ $buttons.= '<input name="submit" type="submit" value="' . $button_text . '" class="' . $args['button_class'] . '" />' . $args['n'];
1038
+
1039
+ /**
1040
+ * Filter the HTML for form buttons.
1041
+ *
1042
+ * The string passed through the filter includes the buttons, as well as the HTML wrapper elements.
1043
+ *
1044
+ * @since 2.9.0
1045
+ *
1046
+ * @param string $buttons The generated HTML of the form buttons.
1047
+ * @param string $tag Toggle new registration or profile update. new|edit.
1048
+ */
1049
+ $buttons = apply_filters( 'wpmem_register_form_buttons', $buttons, $tag );
1050
+
1051
+ // Add the buttons to the form.
1052
+ $form.= $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'];
1053
+
1054
+ // Add the required field notation to the bottom of the form.
1055
+ $form.= $args['req_label_before'] . $args['req_label'] . $args['req_label_after'];
1056
+
1057
+ // Apply the heading.
1058
+ /**
1059
+ * Filter the registration form heading.
1060
+ *
1061
+ * @since 2.8.2
1062
+ *
1063
+ * @param string $str
1064
+ * @param string $tag Toggle new registration or profile update. new|edit.
1065
+ */
1066
+ $heading = ( !$heading ) ? apply_filters( 'wpmem_register_heading', $wpmem->get_text( 'register_heading' ), $tag ) : $heading;
1067
+ $form = $args['heading_before'] . $heading . $args['heading_after'] . $args['n'] . $form;
1068
+
1069
+ // Apply fieldset wrapper.
1070
+ $form = $args['fieldset_before'] . $args['n'] . $form . $args['n'] . $args['fieldset_after'];
1071
+
1072
+ // Apply attribution if enabled.
1073
+ $form = $form . wpmem_inc_attribution();
1074
+
1075
+ // Apply nonce.
1076
+ $form = ( defined( 'WPMEM_USE_NONCE' ) || $args['use_nonce'] ) ? wp_nonce_field( 'wpmem-validate-submit', 'wpmem-form-submit' ) . $args['n'] . $form : $form;
1077
+
1078
+ // Apply form wrapper.
1079
+ $enctype = ( $enctype == 'multipart/form-data' ) ? ' enctype="multipart/form-data"' : '';
1080
+ $post_to = get_permalink();
1081
+ $form = '<form name="form" method="post"' . $enctype . ' action="' . $post_to . '" id="' . $args['form_id'] . '" class="' . $args['form_class'] . '">' . $args['n'] . $form . $args['n'] . '</form>';
1082
+
1083
+ // Apply anchor.
1084
+ $form = '<a name="register"></a>' . $args['n'] . $form;
1085
+
1086
+ // Apply main div wrapper.
1087
+ $form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'] . $args['n'];
1088
+
1089
+ // Apply wpmem_txt wrapper.
1090
+ $form = $args['txt_before'] . $form . $args['txt_after'];
1091
+
1092
+ // Remove line breaks if enabled for easier filtering later.
1093
+ $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
1094
+
1095
+ /**
1096
+ * Filter the generated HTML of the entire form.
1097
+ *
1098
+ * @since 2.7.4
1099
+ *
1100
+ * @param string $form The HTML of the final generated form.
1101
+ * @param string $tag Toggle new registration or profile update. new|edit.
1102
+ * @param array $rows {
1103
+ * An array containing the form rows.
1104
+ *
1105
+ * @type string order Field display order.
1106
+ * @type string meta Field meta tag (not used for display).
1107
+ * @type string type Input field type (not used for display).
1108
+ * @type string value Input field value (not used for display).
1109
+ * @type string values The possible values for the field (dropdown, multiple select/checkbox, radio group).
1110
+ * @type string label_text Raw text for the label (not used for display).
1111
+ * @type string row_before Opening wrapper tag around the row.
1112
+ * @type string label Label tag.
1113
+ * @type string field_before Opening wrapper tag before the input tag.
1114
+ * @type string field The field input tag.
1115
+ * @type string field_after Closing wrapper tag around the input tag.
1116
+ * @type string row_after Closing wrapper tag around the row.
1117
+ * }
1118
+ * @param string $hidden The HTML string of hidden fields
1119
+ */
1120
+ $form = apply_filters( 'wpmem_register_form', $form, $tag, $rows, $hidden );
1121
+
1122
+ /**
1123
+ * Filter before the form.
1124
+ *
1125
+ * This rarely used filter allows you to stick any string onto the front of
1126
+ * the generated form.
1127
+ *
1128
+ * @since 2.7.4
1129
+ *
1130
+ * @param string $str The HTML to add before the form. Default null.
1131
+ * @param string $tag Toggle new registration or profile update. new|edit.
1132
+ */
1133
+ $form = apply_filters( 'wpmem_register_form_before', '', $tag ) . $form;
1134
+
1135
+ // Return the generated form.
1136
+ return $form;
1137
+ } // End wpmem_inc_registration.
1138
+
1139
  } // End of WP_Members_Forms class.
inc/class-wp-members-user.php ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The WP_Members_User Class.
4
+ *
5
+ * This is the WP_Members User object class. This class contains functions
6
+ * for login, logout, registration and other user related methods.
7
+ *
8
+ * @package WP-Members
9
+ * @subpackage WP_Members_User Object Class
10
+ * @since 3.0.0
11
+ */
12
+
13
+ class WP_Members_User {
14
+
15
+ /**
16
+ * Container for reg form data.
17
+ *
18
+ * @since 3.1.7
19
+ * @access public
20
+ * @var array
21
+ */
22
+ public $post_data = array();
23
+
24
+ /**
25
+ * Initilize the User object.
26
+ *
27
+ * @since 3.1.7
28
+ */
29
+ function __construct() {
30
+ //add_action( 'user_register', array( $this, 'register' ), 9 ); // @todo This need rigorous testing, especially front end processing such as WC.
31
+ add_action( 'wpmem_register_redirect', array( $this, 'register_redirect' ) );
32
+ }
33
+
34
+ /**
35
+ * Handle user login.
36
+ *
37
+ * Built from, but replaces, the original wpmem_login() function
38
+ * from core.php. wpmem_login() is currently maintained as a
39
+ * wrapper and is the direct function called for login.
40
+ *
41
+ * @since 3.1.7
42
+ *
43
+ * @return string Returns "loginfailed" if failed login.
44
+ */
45
+ function login() {
46
+
47
+ $creds = array( 'user_login' => 'log', 'user_password' => 'pwd', 'remember' => 'rememberme', 'redirect_to' => 'redirect_to' );
48
+ /**
49
+ * Filter the $fields the function handles.
50
+ *
51
+ * @since 3.1.7
52
+ *
53
+ * @param array $creds
54
+ */
55
+ $creds = apply_filters( 'wpmem_login_fields', $creds );
56
+ foreach ( $creds as $key => $val ) {
57
+ $creds[ $key ] = ( 'user_login' == $key ) ? sanitize_user( wpmem_get( $val ) ) : wpmem_get( $val );
58
+ }
59
+
60
+ $user = wp_signon( $creds, is_ssl() );
61
+
62
+ if ( is_wp_error( $user ) ) {
63
+ return "loginfailed";
64
+ } else {
65
+ $redirect_to = wpmem_get( 'redirect_to', false );
66
+ $redirect_to = ( $redirect_to ) ? esc_url_raw( trim( $redirect_to ) ) : esc_url_raw( wpmem_current_url() );
67
+ /** This filter defined in wp-login.php */
68
+ $redirect_to = apply_filters( 'login_redirect', $redirect_to, wpmem_current_url(), $user );
69
+ /**
70
+ * Filter the redirect url.
71
+ *
72
+ * @since 2.7.7
73
+ *
74
+ * @param string $redirect_to The url to direct to.
75
+ * @param int $user->ID The user's primary key ID.
76
+ */
77
+ $redirect_to = apply_filters( 'wpmem_login_redirect', $redirect_to, $user->ID );
78
+ wp_redirect( $redirect_to );
79
+ exit();
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Handle user logout.
85
+ *
86
+ * Built from, but replaces, the original wpmem_logout() function
87
+ * from core.php. wpmem_logout() is currently maintained as a
88
+ * wrapper and is the direct function called for logout.
89
+ *
90
+ * @since 3.1.7
91
+ *
92
+ * @param string $redirect_to URL to redirect the user to (default: false).
93
+ */
94
+ function logout( $redirect_to = false ) {
95
+ // Default redirect URL.
96
+ $redirect_to = ( $redirect_to ) ? $redirect_to : home_url();
97
+
98
+ /**
99
+ * Filter where the user goes when logged out.
100
+ *
101
+ * @since 2.7.1
102
+ * @since 3.1.7 Moved to WP_Members_Users Class.
103
+ *
104
+ * @param string The blog home page.
105
+ */
106
+ $redirect_to = apply_filters( 'wpmem_logout_redirect', $redirect_to );
107
+
108
+ wp_destroy_current_session();
109
+ wp_clear_auth_cookie();
110
+
111
+ /** This action is defined in /wp-includes/pluggable.php. */
112
+ do_action( 'wp_logout' );
113
+
114
+ wp_redirect( $redirect_to );
115
+ exit();
116
+ }
117
+
118
+ /**
119
+ * User registration functions.
120
+ *
121
+ * @since 3.1.7
122
+ *
123
+ * @global object $wpmem
124
+ * @param int $user_id
125
+ */
126
+ function register( $user_id ) {
127
+
128
+ global $wpmem;
129
+
130
+ // Put user ID into post_data array.
131
+ $wpmem->user->post_data['ID'] = $user_id;
132
+
133
+ // Set remaining fields to wp_usermeta table.
134
+ $new_user_fields_meta = array( 'user_url', 'first_name', 'last_name', 'description', 'jabber', 'aim', 'yim' );
135
+ foreach ( $wpmem->fields as $meta_key => $field ) {
136
+ // If the field is not excluded, update accordingly.
137
+ if ( ! in_array( $meta_key, $wpmem->excluded_meta ) && ! in_array( $meta_key, $new_user_fields_meta ) ) {
138
+ if ( $field['register'] && 'user_email' != $meta_key ) {
139
+ update_user_meta( $user_id, $meta_key, $this->post_data[ $meta_key ] );
140
+ }
141
+ }
142
+ }
143
+
144
+ // Capture IP address of user at registration.
145
+ update_user_meta( $user_id, 'wpmem_reg_ip', $this->post_data['wpmem_reg_ip'] );
146
+
147
+ // Store the registration url.
148
+ update_user_meta( $user_id, 'wpmem_reg_url', $this->post_data['wpmem_reg_url'] );
149
+
150
+ // Set user expiration, if used.
151
+ if ( $wpmem->use_exp == 1 && $wpmem->mod_reg != 1 ) {
152
+ if ( function_exists( 'wpmem_set_exp' ) ) {
153
+ wpmem_set_exp( $user_id );
154
+ }
155
+ }
156
+
157
+ // Handle file uploads, if any.
158
+ if ( ! empty( $_FILES ) ) {
159
+
160
+ foreach ( $wpmem->fields as $meta_key => $field ) {
161
+
162
+ if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && is_array( $_FILES[ $meta_key ] ) ) {
163
+
164
+ // Upload the file and save it as an attachment.
165
+ $file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $user_id );
166
+
167
+ // Save the attachment ID as user meta.
168
+ update_user_meta( $user_id, $meta_key, $file_post_id );
169
+ }
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Fires after user insertion but before email.
175
+ *
176
+ * @since 2.7.2
177
+ *
178
+ * @param array $this->post_data The user's submitted registration data.
179
+ */
180
+ do_action( 'wpmem_post_register_data', $this->post_data );
181
+
182
+ // Send a notification email to the user.
183
+ wpmem_inc_regemail( $user_id, $this->post_data['password'], $wpmem->mod_reg, $wpmem->fields, $this->post_data );
184
+
185
+ // Notify admin of new reg, if needed.
186
+ if ( $wpmem->notify == 1 ) {
187
+ wpmem_notify_admin( $user_id, $wpmem->fields, $this->post_data );
188
+ }
189
+
190
+ /**
191
+ * Fires after registration is complete.
192
+ *
193
+ * @since 2.7.1
194
+ * @since 3.1.0 Added $fields
195
+ * @since 3.1.7 Changed $fields to $wpmem->user->post_data
196
+ */
197
+ do_action( 'wpmem_register_redirect', $this->post_data );
198
+
199
+ }
200
+
201
+ /**
202
+ * Redirects user on registration.
203
+ *
204
+ * @since 3.1.7
205
+ */
206
+ function register_redirect() {
207
+ $redirect_to = wpmem_get( 'redirect_to', false );
208
+ if ( $redirect_to ) {
209
+ $nonce_url = wp_nonce_url( $redirect_to, 'register_redirect', 'reg_nonce' );
210
+ wp_redirect( $nonce_url );
211
+ exit();
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Password change or reset.
217
+ *
218
+ * @since 3.1.7
219
+ *
220
+ * @param string $action
221
+ * @return string $result
222
+ */
223
+ function password_update( $action ) {
224
+ if ( isset( $_POST['formsubmit'] ) ) {
225
+ $params = ( 'reset' == $action ) ? array( 'user', 'email' ) : array( 'pass1', 'pass2' );
226
+ $args = array(
227
+ $params[0] => wpmem_get( $params[0], false ),
228
+ $params[1] => wpmem_get( $params[1], false ),
229
+ );
230
+ return ( 'reset' == $action ) ? $this->password_reset( $args ) : $this->password_change( $args );
231
+ }
232
+ return;
233
+ }
234
+
235
+ /**
236
+ * Change a user's password()
237
+ *
238
+ * @since 3.1.7
239
+ *
240
+ * @return
241
+ */
242
+ function password_change( $args ) {
243
+ global $user_ID;
244
+ $is_error = false;
245
+ // Check for both fields being empty.
246
+ $is_error = ( ! $args['pass1'] && ! $args['pass2'] ) ? "pwdchangempty" : $is_error;
247
+ // Make sure the fields match.
248
+ $is_error = ( $args['pass1'] != $args['pass2'] ) ? "pwdchangerr" : $is_error;
249
+ /**
250
+ * Filters the password change error.
251
+ *
252
+ * @since 3.1.5
253
+ * @since 3.1.7 Moved to user object.
254
+ *
255
+ * @param string $is_error
256
+ * @param int $user_ID The user's numeric ID.
257
+ * @param string $args['pass1'] The user's new plain text password.
258
+ */
259
+ $is_error = apply_filters( 'wpmem_pwd_change_error', $is_error, $user_ID, $args['pass1'] );
260
+ if ( $is_error ) {
261
+ return $is_error;
262
+ }
263
+ // Update user password.
264
+ wp_set_password( $args['pass1'], $user_ID );
265
+ /**
266
+ * Fires after password change.
267
+ *
268
+ * @since 2.9.0
269
+ * @since 3.0.5 Added $args['pass1'] to arguments passed.
270
+ * @since 3.1.7 Moved to user object.
271
+ *
272
+ * @param int $user_ID The user's numeric ID.
273
+ * @param string $args['pass1'] The user's new plain text password.
274
+ */
275
+ do_action( 'wpmem_pwd_change', $user_ID, $args['pass1'] );
276
+ return "pwdchangesuccess";
277
+ }
278
+
279
+ /**
280
+ * Reset a user's password.
281
+ *
282
+ * @since 3.1.7
283
+ *
284
+ */
285
+ function password_reset( $args ) {
286
+ global $wpmem;
287
+ /**
288
+ * Filter the password reset arguments.
289
+ *
290
+ * @since 2.7.1
291
+ * @since 3.1.7 Moved to user object.
292
+ *
293
+ * @param array The username and email.
294
+ */
295
+ $arr = apply_filters( 'wpmem_pwdreset_args', $args );
296
+ if ( ! $arr['user'] || ! $arr['email'] ) {
297
+ // There was an empty field.
298
+ return "pwdreseterr";
299
+
300
+ } else {
301
+
302
+ if ( username_exists( $arr['user'] ) ) {
303
+ $user = get_user_by( 'login', $arr['user'] );
304
+ if ( strtolower( $user->user_email ) !== strtolower( $arr['email'] ) || ( ( $wpmem->mod_reg == 1 ) && ( get_user_meta( $user->ID, 'active', true ) != 1 ) ) ) {
305
+ // The username was there, but the email did not match OR the user hasn't been activated.
306
+ return "pwdreseterr";
307
+ } else {
308
+ // Generate a new password.
309
+ $new_pass = wp_generate_password();
310
+ // Update the users password.
311
+ wp_set_password( $new_pass, $user->ID );
312
+ // Send it in an email.
313
+ wpmem_inc_regemail( $user->ID, $new_pass, 3 );
314
+ /**
315
+ * Fires after password reset.
316
+ *
317
+ * @since 2.9.0
318
+ * @since 3.0.5 Added $new_pass to arguments passed.
319
+ * @since 3.1.7 Moved to user object.
320
+ *
321
+ * @param int $user_ID The user's numeric ID.
322
+ * @param string $new_pass The new plain text password.
323
+ */
324
+ do_action( 'wpmem_pwd_reset', $user->ID, $new_pass );
325
+ return "pwdresetsuccess";
326
+ }
327
+ } else {
328
+ // Username did not exist.
329
+ return "pwdreseterr";
330
+ }
331
+ }
332
+ return;
333
+ }
334
+
335
+ }
inc/class-wp-members.php CHANGED
@@ -13,20 +13,158 @@
13
 
14
  class WP_Members {
15
 
 
 
 
 
 
 
 
16
  public $version;
 
 
 
 
 
 
 
 
17
  public $block;
 
 
 
 
 
 
 
 
18
  public $show_excerpt;
 
 
 
 
 
 
 
 
19
  public $show_login;
 
 
 
 
 
 
 
 
20
  public $show_reg;
 
 
 
 
 
 
 
 
21
  public $autoex;
 
 
 
 
 
 
 
 
22
  public $notify;
 
 
 
 
 
 
 
 
23
  public $mod_reg;
 
 
 
 
 
 
 
 
24
  public $captcha;
 
 
 
 
 
 
 
 
25
  public $use_exp;
 
 
 
 
 
 
 
 
26
  public $use_trial;
 
 
 
 
 
 
 
 
27
  public $warnings;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  public $user_pages;
 
 
 
 
 
 
 
 
29
  public $post_types;
 
 
 
 
 
 
 
 
 
30
 
31
  /**
32
  * Plugin initialization function.
@@ -36,6 +174,7 @@ class WP_Members {
36
  */
37
  function __construct() {
38
 
 
39
  $this->load_dependencies();
40
 
41
  /**
@@ -74,6 +213,9 @@ class WP_Members {
74
  // Load api.
75
  $this->api = new WP_Members_API;
76
 
 
 
 
77
  /**
78
  * Fires after main settings are loaded.
79
  *
@@ -131,6 +273,9 @@ class WP_Members {
131
  add_shortcode( 'wpmem_profile', 'wpmem_sc_user_profile' );
132
  add_shortcode( 'wpmem_loginout', 'wpmem_sc_loginout' );
133
  add_shortcode( 'wpmem_tos', 'wpmem_sc_tos' );
 
 
 
134
 
135
  /**
136
  * Fires after shortcodes load.
@@ -159,7 +304,7 @@ class WP_Members {
159
  // Add actions.
160
  add_action( 'template_redirect', array( $this, 'get_action' ) );
161
  add_action( 'widgets_init', 'widget_wpmemwidget_init' ); // initializes the widget
162
- add_action( 'admin_init', 'wpmem_chk_admin' ); // check user role to load correct dashboard
163
  add_action( 'admin_menu', 'wpmem_admin_options' ); // adds admin menu
164
  add_action( 'user_register', 'wpmem_wp_reg_finalize' ); // handles wp native registration
165
  add_action( 'login_enqueue_scripts', 'wpmem_wplogin_stylesheet' ); // styles the native registration
@@ -171,6 +316,7 @@ class WP_Members {
171
  add_filter( 'register_form', 'wpmem_wp_register_form' ); // adds fields to the default wp registration
172
  add_filter( 'registration_errors', 'wpmem_wp_reg_validate', 10, 3 ); // native registration validation
173
  add_filter( 'comments_open', 'wpmem_securify_comments', 99 ); // securifies the comments
 
174
 
175
  // If registration is moderated, check for activation (blocks backend login by non-activated users).
176
  if ( $this->mod_reg == 1 ) {
@@ -272,6 +418,7 @@ class WP_Members {
272
  include( $wpmem_pluggable );
273
  }
274
 
 
275
  require_once( WPMEM_PATH . 'inc/class-wp-members-api.php' );
276
  require_once( WPMEM_PATH . 'inc/class-wp-members-forms.php' );
277
  require_once( WPMEM_PATH . 'inc/class-wp-members-widget.php' );
@@ -282,6 +429,37 @@ class WP_Members {
282
  require_once( WPMEM_PATH . 'inc/sidebar.php' );
283
  require_once( WPMEM_PATH . 'inc/shortcodes.php' );
284
  require_once( WPMEM_PATH . 'inc/email.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  }
286
 
287
  /**
@@ -294,11 +472,18 @@ class WP_Members {
294
  function get_action() {
295
 
296
  // Get the action being done (if any).
297
- $this->action = ( isset( $_REQUEST['a'] ) ) ? trim( $_REQUEST['a'] ) : '';
298
 
299
  // For backward compatibility with processes that check $wpmem_a.
300
  global $wpmem_a;
301
  $wpmem_a = $this->action;
 
 
 
 
 
 
 
302
 
303
  // Get the regchk value (if any).
304
  $this->regchk = $this->get_regchk( $this->action );
@@ -362,6 +547,7 @@ class WP_Members {
362
  * This value determines what happens in the wpmem_securify() function.
363
  *
364
  * @since 2.9.0
 
365
  *
366
  * @param string $this->regchk The value of wpmem_regchk.
367
  * @param string $this->action The $wpmem_a action.
@@ -414,6 +600,7 @@ class WP_Members {
414
  * Filter the block arguments.
415
  *
416
  * @since 2.9.8
 
417
  *
418
  * @param array $args Null.
419
  * @param array $defaults Although you are not filtering the defaults, knowing what they are can assist developing more powerful functions.
@@ -487,8 +674,6 @@ class WP_Members {
487
 
488
  // Block/unblock Posts.
489
  if ( ! is_user_logged_in() && $this->is_blocked() == true ) {
490
-
491
- include_once( WPMEM_PATH . 'inc/dialogs.php' );
492
 
493
  //Show the login and registration forms.
494
  if ( $this->regchk ) {
@@ -561,7 +746,7 @@ class WP_Members {
561
  */
562
  $content = apply_filters( 'wpmem_securify', $content );
563
 
564
- if ( strstr( $content, '[wpmem_txt]' ) ) {
565
  // Fix the wptexturize.
566
  remove_filter( 'the_content', 'wpautop' );
567
  remove_filter( 'the_content', 'wptexturize' );
@@ -581,6 +766,8 @@ class WP_Members {
581
  * @param string $form The form being generated.
582
  */
583
  function load_fields( $form = 'default' ) {
 
 
584
  $fields = get_option( 'wpmembers_fields' );
585
 
586
  // Validate fields settings.
@@ -626,7 +813,7 @@ class WP_Members {
626
  case 'radio':
627
  $this->fields[ $meta_key ]['values'] = $val[7];
628
  $this->fields[ $meta_key ]['delimiter'] = ( isset( $val[8] ) ) ? $val[8] : '|';
629
- $this->fields[ $meta_key ]['options'] = array();
630
  foreach ( $val[7] as $value ) {
631
  $pieces = explode( $this->fields[ $meta_key ]['delimiter'], trim( $value ) );
632
  if ( $pieces[1] != '' ) {
@@ -849,6 +1036,12 @@ class WP_Members {
849
  */
850
  function load_admin_api() {
851
  if ( is_admin() ) {
 
 
 
 
 
 
852
  $this->admin = new WP_Members_Admin_API;
853
  }
854
  }
13
 
14
  class WP_Members {
15
 
16
+ /**
17
+ * Plugin version.
18
+ *
19
+ * @since 3.0.0
20
+ * @access public
21
+ * @var string
22
+ */
23
  public $version;
24
+
25
+ /**
26
+ * Content block settings.
27
+ *
28
+ * @since 3.0.0
29
+ * @access public
30
+ * @var array
31
+ */
32
  public $block;
33
+
34
+ /**
35
+ * Excerpt settings.
36
+ *
37
+ * @since 3.0.0
38
+ * @access public
39
+ * @var array
40
+ */
41
  public $show_excerpt;
42
+
43
+ /**
44
+ * Show login form settings.
45
+ *
46
+ * @since 3.0.0
47
+ * @access public
48
+ * @var array
49
+ */
50
  public $show_login;
51
+
52
+ /**
53
+ * Show registration form settings.
54
+ *
55
+ * @since 3.0.0
56
+ * @access public
57
+ * @var array
58
+ */
59
  public $show_reg;
60
+
61
+ /**
62
+ * Auto-excerpt settings.
63
+ *
64
+ * @since 3.0.0
65
+ * @access public
66
+ * @var array
67
+ */
68
  public $autoex;
69
+
70
+ /**
71
+ * Notify admin settings.
72
+ *
73
+ * @since 3.0.0
74
+ * @access public
75
+ * @var string
76
+ */
77
  public $notify;
78
+
79
+ /**
80
+ * Moderated registration settings.
81
+ *
82
+ * @since 3.0.0
83
+ * @access public
84
+ * @var string
85
+ */
86
  public $mod_reg;
87
+
88
+ /**
89
+ * Captcha settings.
90
+ *
91
+ * @since 3.0.0
92
+ * @access public
93
+ * @var array
94
+ */
95
  public $captcha;
96
+
97
+ /**
98
+ * Enable expiration extension settings.
99
+ *
100
+ * @since 3.0.0
101
+ * @access public
102
+ * @var string
103
+ */
104
  public $use_exp;
105
+
106
+ /**
107
+ * Expiration extension enable trial period.
108
+ *
109
+ * @since 3.0.0
110
+ * @access public
111
+ * @var string
112
+ */
113
  public $use_trial;
114
+
115
+ /**
116
+ *
117
+ *
118
+ * @since 3.0.0
119
+ * @access public
120
+ * @var array
121
+ */
122
  public $warnings;
123
+
124
+ /**
125
+ * Current plugin action container.
126
+ *
127
+ * @since 3.0.0
128
+ * @access public
129
+ * @var string
130
+ */
131
+ public $action;
132
+
133
+ /**
134
+ * Regchk container.
135
+ *
136
+ * @since 3.0.0
137
+ * @access public
138
+ * @var string
139
+ */
140
+ public $regchk;
141
+
142
+ /**
143
+ * User page settings.
144
+ *
145
+ * @since 3.0.0
146
+ * @access public
147
+ * @var array
148
+ */
149
  public $user_pages;
150
+
151
+ /**
152
+ * Custom Post Type settings.
153
+ *
154
+ * @since 3.0.0
155
+ * @access public
156
+ * @var array
157
+ */
158
  public $post_types;
159
+
160
+ /**
161
+ * Setting for applying texturization.
162
+ *
163
+ * @since 3.1.7
164
+ * @access public
165
+ * @var boolean
166
+ */
167
+ public $texturize;
168
 
169
  /**
170
  * Plugin initialization function.
174
  */
175
  function __construct() {
176
 
177
+ // Load dependent files.
178
  $this->load_dependencies();
179
 
180
  /**
213
  // Load api.
214
  $this->api = new WP_Members_API;
215
 
216
+ // Load user functions.
217
+ $this->user = new WP_Members_User;
218
+
219
  /**
220
  * Fires after main settings are loaded.
221
  *
273
  add_shortcode( 'wpmem_profile', 'wpmem_sc_user_profile' );
274
  add_shortcode( 'wpmem_loginout', 'wpmem_sc_loginout' );
275
  add_shortcode( 'wpmem_tos', 'wpmem_sc_tos' );
276
+ add_shortcode( 'wpmem_avatar', 'wpmem_sc_avatar' );
277
+ add_shortcode( 'wpmem_login_link', 'wpmem_sc_link' );
278
+ add_shortcode( 'wpmem_reg_link', 'wpmem_sc_link' );
279
 
280
  /**
281
  * Fires after shortcodes load.
304
  // Add actions.
305
  add_action( 'template_redirect', array( $this, 'get_action' ) );
306
  add_action( 'widgets_init', 'widget_wpmemwidget_init' ); // initializes the widget
307
+ add_action( 'admin_init', array( $this, 'load_admin' ) ); // check user role to load correct dashboard
308
  add_action( 'admin_menu', 'wpmem_admin_options' ); // adds admin menu
309
  add_action( 'user_register', 'wpmem_wp_reg_finalize' ); // handles wp native registration
310
  add_action( 'login_enqueue_scripts', 'wpmem_wplogin_stylesheet' ); // styles the native registration
316
  add_filter( 'register_form', 'wpmem_wp_register_form' ); // adds fields to the default wp registration
317
  add_filter( 'registration_errors', 'wpmem_wp_reg_validate', 10, 3 ); // native registration validation
318
  add_filter( 'comments_open', 'wpmem_securify_comments', 99 ); // securifies the comments
319
+ add_filter( 'wpmem_securify', 'wpmem_reg_securify' ); // adds success message on login form if redirected
320
 
321
  // If registration is moderated, check for activation (blocks backend login by non-activated users).
322
  if ( $this->mod_reg == 1 ) {
418
  include( $wpmem_pluggable );
419
  }
420
 
421
+ require_once( WPMEM_PATH . 'inc/class-wp-members-user.php' );
422
  require_once( WPMEM_PATH . 'inc/class-wp-members-api.php' );
423
  require_once( WPMEM_PATH . 'inc/class-wp-members-forms.php' );
424
  require_once( WPMEM_PATH . 'inc/class-wp-members-widget.php' );
429
  require_once( WPMEM_PATH . 'inc/sidebar.php' );
430
  require_once( WPMEM_PATH . 'inc/shortcodes.php' );
431
  require_once( WPMEM_PATH . 'inc/email.php' );
432
+ require_once( WPMEM_PATH . 'inc/deprecated.php' );
433
+ }
434
+
435
+ /**
436
+ * Load admin API and dependencies.
437
+ *
438
+ * Determines which scripts to load and actions to use based on the
439
+ * current users capabilities.
440
+ *
441
+ * @since 2.5.2
442
+ * @since 3.1.0 Added admin api object.
443
+ * @since 3.1.7 Moved from main plugin file as wpmem_chk_admin() to main object.
444
+ */
445
+ function load_admin() {
446
+
447
+ /**
448
+ * Fires before initialization of admin options.
449
+ *
450
+ * @since 2.9.0
451
+ */
452
+ do_action( 'wpmem_pre_admin_init' );
453
+
454
+ // Initilize the admin api.
455
+ $this->load_admin_api();
456
+
457
+ /**
458
+ * Fires after initialization of admin options.
459
+ *
460
+ * @since 2.9.0
461
+ */
462
+ do_action( 'wpmem_after_admin_init' );
463
  }
464
 
465
  /**
472
  function get_action() {
473
 
474
  // Get the action being done (if any).
475
+ $this->action = wpmem_get( 'a', '', 'request' ); //( isset( $_REQUEST['a'] ) ) ? trim( $_REQUEST['a'] ) : '';
476
 
477
  // For backward compatibility with processes that check $wpmem_a.
478
  global $wpmem_a;
479
  $wpmem_a = $this->action;
480
+
481
+ /**
482
+ * Fires when the wpmem action is retrieved.
483
+ *
484
+ * @since 3.1.7
485
+ */
486
+ do_action( 'wpmem_get_action' );
487
 
488
  // Get the regchk value (if any).
489
  $this->regchk = $this->get_regchk( $this->action );
547
  * This value determines what happens in the wpmem_securify() function.
548
  *
549
  * @since 2.9.0
550
+ * @since 3.0.0 Moved to get_regchk() in WP_Members object.
551
  *
552
  * @param string $this->regchk The value of wpmem_regchk.
553
  * @param string $this->action The $wpmem_a action.
600
  * Filter the block arguments.
601
  *
602
  * @since 2.9.8
603
+ * @since 3.0.0 Moved to is_blocked() in WP_Members object.
604
  *
605
  * @param array $args Null.
606
  * @param array $defaults Although you are not filtering the defaults, knowing what they are can assist developing more powerful functions.
674
 
675
  // Block/unblock Posts.
676
  if ( ! is_user_logged_in() && $this->is_blocked() == true ) {
 
 
677
 
678
  //Show the login and registration forms.
679
  if ( $this->regchk ) {
746
  */
747
  $content = apply_filters( 'wpmem_securify', $content );
748
 
749
+ if ( 1 == $this->texturize && strstr( $content, '[wpmem_txt]' ) ) {
750
  // Fix the wptexturize.
751
  remove_filter( 'the_content', 'wpautop' );
752
  remove_filter( 'the_content', 'wptexturize' );
766
  * @param string $form The form being generated.
767
  */
768
  function load_fields( $form = 'default' ) {
769
+
770
+ // Get stored fields settings.
771
  $fields = get_option( 'wpmembers_fields' );
772
 
773
  // Validate fields settings.
813
  case 'radio':
814
  $this->fields[ $meta_key ]['values'] = $val[7];
815
  $this->fields[ $meta_key ]['delimiter'] = ( isset( $val[8] ) ) ? $val[8] : '|';
816
+ $this->fields[ $meta_key ]['options'] = array();
817
  foreach ( $val[7] as $value ) {
818
  $pieces = explode( $this->fields[ $meta_key ]['delimiter'], trim( $value ) );
819
  if ( $pieces[1] != '' ) {
1036
  */
1037
  function load_admin_api() {
1038
  if ( is_admin() ) {
1039
+ /**
1040
+ * Load the admin api class.
1041
+ *
1042
+ * @since 3.1.0
1043
+ */
1044
+ include_once( WPMEM_PATH . 'admin/includes/class-wp-members-admin-api.php' );
1045
  $this->admin = new WP_Members_Admin_API;
1046
  }
1047
  }
inc/core.php CHANGED
@@ -7,12 +7,12 @@
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at http://rocketgeek.com
10
- * Copyright (c) 2006-2016 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @author Chad Butler
15
- * @copyright 2006-2016
16
  */
17
 
18
 
@@ -56,26 +56,6 @@ function wpmem_securify( $content = null ) {
56
  endif;
57
 
58
 
59
- if ( ! function_exists( 'wpmem_block' ) ):
60
- /**
61
- * Determines if content is blocked.
62
- *
63
- * @since 2.6.0
64
- * @since 3.0.0 Now a wrapper for $wpmem->is_blocked().
65
- * @deprecated 3.1.1 Use wpmem_is_blocked() instead.
66
- *
67
- * @global object $wpmem The WP-Members object class.
68
- *
69
- * @return bool $block true if content is blocked, false otherwise.
70
- */
71
- function wpmem_block() {
72
- wpmem_write_log( "wpmem_block() is deprecated as of WP-Members 3.1.1, use wpmem_is_blocked() instead" );
73
- global $wpmem;
74
- return $wpmem->is_blocked();
75
- }
76
- endif;
77
-
78
-
79
  if ( ! function_exists( 'wpmem_check_activated' ) ):
80
  /**
81
  * Checks if a user is activated.
@@ -97,8 +77,7 @@ function wpmem_check_activated( $user, $username, $password ) {
97
  }
98
 
99
  // Activation flag must be validated.
100
- $active = get_user_meta( $user->ID, 'active', true );
101
- if ( $active != 1 ) {
102
  return new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: User has not been activated.', 'wp-members' ) );
103
  }
104
 
@@ -120,63 +99,14 @@ if ( ! function_exists( 'wpmem_login' ) ):
120
  * @since 2.5.2 Now uses wp_signon().
121
  * @since 2.7.7 Sets cookie using wp_set_auth_cookie().
122
  * @since 3.0.0 Removed wp_set_auth_cookie(), this already happens in wp_signon().
 
123
  *
 
124
  * @return string Returns "loginfailed" if the login fails.
125
  */
126
  function wpmem_login() {
127
-
128
- if ( $_POST['log'] && $_POST['pwd'] ) {
129
-
130
- // Get username and sanitize.
131
- $user_login = sanitize_user( $_POST['log'] );
132
-
133
- // Are we setting a forever cookie?
134
- $rememberme = ( isset( $_POST['rememberme'] ) == 'forever' ) ? true : false;
135
-
136
- // Assemble login credentials.
137
- $creds = array();
138
- $creds['user_login'] = $user_login;
139
- $creds['user_password'] = $_POST['pwd'];
140
- $creds['remember'] = $rememberme;
141
-
142
- // Log in the user and get the user object.
143
- $user = wp_signon( $creds, is_ssl() );
144
-
145
- // If no error, user is a valid signon. continue.
146
- if ( ! is_wp_error( $user ) ) {
147
-
148
- // Determine where to put the user after login.
149
- if ( isset( $_POST['redirect_to'] ) ) {
150
- $redirect_to = esc_url_raw( trim( $_POST['redirect_to'] ) );
151
- } else {
152
- $redirect_to = esc_url_raw( $_SERVER['REQUEST_URI'] . ( ( isset( $_SERVER['QUERY_STRING'] ) ) ? $_SERVER['QUERY_STRING'] : '' ) );
153
- }
154
-
155
- /**
156
- * Filter the redirect url.
157
- *
158
- * @since 2.7.7
159
- *
160
- * @param string $redirect_to The url to direct to.
161
- * @param int $user->ID The user's primary key ID.
162
- */
163
- $redirect_to = apply_filters( 'wpmem_login_redirect', $redirect_to, $user->ID );
164
-
165
- // And do the redirect.
166
- wp_redirect( $redirect_to );
167
-
168
- // wp_redirect requires us to exit()
169
- exit();
170
-
171
- } else {
172
-
173
- return "loginfailed";
174
- }
175
-
176
- } else {
177
- // Login failed.
178
- return "loginfailed";
179
- }
180
  } // End of login function.
181
  endif;
182
 
@@ -187,52 +117,14 @@ if ( ! function_exists( 'wpmem_logout' ) ):
187
  *
188
  * @since 2.0.0
189
  * @since 3.1.6 Added wp_destroy_current_session(), removed nocache_headers().
 
190
  *
191
- * @param string $redirect_to The URL to redirect to at logout.
 
192
  */
193
- function wpmem_logout( $redirect_to = null ) {
194
-
195
- // Default redirect URL.
196
- $redirect_to = ( $redirect_to ) ? $redirect_to : get_bloginfo( 'url' );
197
-
198
- /**
199
- * Filter where the user goes when logged out.
200
- *
201
- * @since 2.7.1
202
- *
203
- * @param string The blog home page.
204
- */
205
- $redirect_to = apply_filters( 'wpmem_logout_redirect', $redirect_to );
206
-
207
- wp_destroy_current_session();
208
- wp_clear_auth_cookie();
209
-
210
- /** This action is defined in /wp-includes/pluggable.php. */
211
- do_action( 'wp_logout' );
212
-
213
- wp_redirect( $redirect_to );
214
- exit();
215
- }
216
- endif;
217
-
218
-
219
- if ( ! function_exists( 'wpmem_inc_sidebar' ) ):
220
- /**
221
- * Displays the sidebar.
222
- *
223
- * This function is a wrapper for wpmem_do_sidebar().
224
- *
225
- * @since 2.0.0
226
- * @deprecated Unknown
227
- */
228
- function wpmem_inc_sidebar() {
229
- wpmem_write_log( "WP-Members function wpmem_inc_sidebar() is deprecated. No alternative function exists" );
230
- /**
231
- * Load the sidebar functions.
232
- */
233
- include_once( WPMEM_PATH . 'inc/sidebar.php' );
234
- // Render the sidebar.
235
- wpmem_do_sidebar();
236
  }
237
  endif;
238
 
@@ -256,58 +148,15 @@ if ( ! function_exists( 'wpmem_change_password' ) ):
256
  * Handles user password change (not reset).
257
  *
258
  * @since 2.1.0
 
259
  *
260
  * @global int $user_ID The WordPress user ID.
261
  *
262
  * @return string The value for $wpmem->regchk
263
  */
264
  function wpmem_change_password() {
265
-
266
- global $user_ID;
267
- if ( isset( $_POST['formsubmit'] ) ) {
268
-
269
- $is_error = false;
270
-
271
- $pass1 = wpmem_get( 'pass1', false ); //trim( $_POST['pass1'] );
272
- $pass2 = wpmem_get( 'pass2', false ); //trim( $_POST['pass2'] );
273
-
274
- // Check for both fields being empty.
275
- $is_error = ( ! $pass1 && ! $pass2 ) ? "pwdchangempty" : $is_error;
276
- // Make sure the fields match.
277
- $is_error = ( $pass1 != $pass2 ) ? "pwdchangerr" : $is_error;
278
-
279
- /**
280
- * Filters the password change error.
281
- *
282
- * @since 3.1.5
283
- *
284
- * @param string $is_error
285
- * @param int $user_ID The user's numeric ID.
286
- * @param string $pass1 The user's new plain text password.
287
- */
288
- $is_error = apply_filters( 'wpmem_pwd_change_error', $is_error, $user_ID, $pass1 );
289
-
290
- if ( $is_error ) {
291
- return $is_error;
292
- }
293
-
294
- // Update user password.
295
- wp_update_user( array ( 'ID' => $user_ID, 'user_pass' => $pass1 ) );
296
-
297
- /**
298
- * Fires after password change.
299
- *
300
- * @since 2.9.0
301
- * @since 3.0.5 Added $pass1 to arguments passed.
302
- *
303
- * @param int $user_ID The user's numeric ID.
304
- * @param string $pass1 The user's new plain text password.
305
- */
306
- do_action( 'wpmem_pwd_change', $user_ID, $pass1 );
307
-
308
- return "pwdchangesuccess";
309
- }
310
- return;
311
  }
312
  endif;
313
 
@@ -317,81 +166,15 @@ if ( ! function_exists( 'wpmem_reset_password' ) ):
317
  * Resets a forgotten password.
318
  *
319
  * @since 2.1.0
 
320
  *
321
  * @global object $wpmem The WP-Members object class.
322
  *
323
  * @return string The value for $wpmem->regchk
324
  */
325
  function wpmem_reset_password() {
326
-
327
  global $wpmem;
328
-
329
- if ( isset( $_POST['formsubmit'] ) ) {
330
-
331
- /**
332
- * Filter the password reset arguments.
333
- *
334
- * @since 2.7.1
335
- *
336
- * @param array The username and email.
337
- */
338
- $arr = apply_filters( 'wpmem_pwdreset_args', array(
339
- 'user' => ( isset( $_POST['user'] ) ) ? trim( $_POST['user'] ) : '',
340
- 'email' => ( isset( $_POST['email'] ) ) ? trim( $_POST['email'] ) : '',
341
- ) );
342
-
343
- if ( ! $arr['user'] || ! $arr['email'] ) {
344
-
345
- // There was an empty field.
346
- return "pwdreseterr";
347
-
348
- } else {
349
-
350
- if ( username_exists( $arr['user'] ) ) {
351
-
352
- $user = get_user_by( 'login', $arr['user'] );
353
-
354
- if ( strtolower( $user->user_email ) !== strtolower( $arr['email'] ) || ( ( $wpmem->mod_reg == 1 ) && ( get_user_meta( $user->ID, 'active', true ) != 1 ) ) ) {
355
- // The username was there, but the email did not match OR the user hasn't been activated.
356
- return "pwdreseterr";
357
-
358
- } else {
359
-
360
- // Generate a new password.
361
- $new_pass = wp_generate_password();
362
-
363
- // Update the users password.
364
- wp_update_user( array ( 'ID' => $user->ID, 'user_pass' => $new_pass ) );
365
-
366
- /**
367
- * Load the email functions.
368
- */
369
- require_once( WPMEM_PATH . 'inc/email.php' );
370
-
371
- // Send it in an email.
372
- wpmem_inc_regemail( $user->ID, $new_pass, 3 );
373
-
374
- /**
375
- * Fires after password reset.
376
- *
377
- * @since 2.9.0
378
- * @since 3.0.5 Added $pass1 to arguments passed.
379
- *
380
- * @param int $user_ID The user's numeric ID.
381
- * @param string $new_pass The new plain text password.
382
- */
383
- do_action( 'wpmem_pwd_reset', $user->ID, $new_pass );
384
-
385
- return "pwdresetsuccess";
386
- }
387
- } else {
388
-
389
- // Username did not exist.
390
- return "pwdreseterr";
391
- }
392
- }
393
- }
394
- return;
395
  }
396
  endif;
397
 
@@ -459,7 +242,7 @@ function wpmem_wp_reg_validate( $errors, $sanitized_user_login, $user_email ) {
459
  // Get any meta fields that should be excluded.
460
  $exclude = wpmem_get_excluded_meta( 'register' );
461
 
462
- foreach ( wpmem_fields() as $meta_key => $field ) {
463
  $is_error = false;
464
  if ( $field['required'] && $meta_key != 'user_email' && ! in_array( $meta_key, $exclude ) ) {
465
  if ( ( $field['type'] == 'checkbox' || $field['type'] == 'multicheckbox' || $field['type'] == 'multiselect' || $field['type'] == 'radio' ) && ( ! isset( $_POST[ $meta_key ] ) ) ) {
@@ -490,13 +273,16 @@ function wpmem_wp_reg_validate( $errors, $sanitized_user_login, $user_email ) {
490
  function wpmem_wp_reg_finalize( $user_id ) {
491
 
492
  global $wpmem;
 
493
  $is_native = ( isset( $_POST['wp-submit'] ) && $_POST['wp-submit'] == esc_attr( __( 'Register' ) ) ) ? true : false;
 
494
  $is_add_new = ( isset( $_POST['action'] ) && $_POST['action'] == 'createuser' ) ? true : false;
 
495
  $is_woo = ( isset( $_POST['woocommerce_checkout_place_order'] ) || isset( $_POST['woocommerce-register-nonce'] ) ) ? true : false;
496
  if ( $is_native || $is_add_new || $is_woo ) {
497
  // Get any excluded meta fields.
498
  $exclude = wpmem_get_excluded_meta( 'register' );
499
- foreach ( wpmem_fields() as $meta_key => $field ) {
500
  if ( isset( $_POST[ $meta_key ] ) && ! in_array( $meta_key, $exclude ) && 'file' != $field['type'] && 'image' != $field['type'] ) {
501
  if ( 'multiselect' == $field['type'] || 'multicheckbox' == $field['type'] ) {
502
  $data = implode( $field['delimiter'], $_POST[ $meta_key ] );
@@ -506,13 +292,17 @@ function wpmem_wp_reg_finalize( $user_id ) {
506
  update_user_meta( $user_id, $meta_key, sanitize_text_field( $data ) );
507
  }
508
  }
509
-
 
 
 
510
  // If moderated registration and activate is checked, set active flags.
511
- if ( is_admin() && $is_add_new && 1 == $wpmem->mod_reg && isset( $_POST['activate_user'] ) ) {
512
  update_user_meta( $user_id, 'active', 1 );
513
  wpmem_set_user_status( $user_id, 0 );
514
  }
515
  }
 
516
  return;
517
  }
518
 
@@ -615,4 +405,43 @@ function wpmem_retrieve_username() {
615
  return;
616
  }
617
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
618
  // End of file.
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at http://rocketgeek.com
10
+ * Copyright (c) 2006-2017 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @author Chad Butler
15
+ * @copyright 2006-2017
16
  */
17
 
18
 
56
  endif;
57
 
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  if ( ! function_exists( 'wpmem_check_activated' ) ):
60
  /**
61
  * Checks if a user is activated.
77
  }
78
 
79
  // Activation flag must be validated.
80
+ if ( ! wpmem_is_user_activated( $user->ID ) ) {
 
81
  return new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: User has not been activated.', 'wp-members' ) );
82
  }
83
 
99
  * @since 2.5.2 Now uses wp_signon().
100
  * @since 2.7.7 Sets cookie using wp_set_auth_cookie().
101
  * @since 3.0.0 Removed wp_set_auth_cookie(), this already happens in wp_signon().
102
+ * @since 3.1.7 Now a wrapper for login() in WP_Members_Users Class.
103
  *
104
+ * @global object $wpmem
105
  * @return string Returns "loginfailed" if the login fails.
106
  */
107
  function wpmem_login() {
108
+ global $wpmem;
109
+ return $wpmem->user->login();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  } // End of login function.
111
  endif;
112
 
117
  *
118
  * @since 2.0.0
119
  * @since 3.1.6 Added wp_destroy_current_session(), removed nocache_headers().
120
+ * @since 3.1.7 Now a wrapper for logout() in WP_Members_Users Class.
121
  *
122
+ * @global object $wpmem
123
+ * @param string $redirect_to The URL to redirect to at logout.
124
  */
125
+ function wpmem_logout( $redirect_to = false ) {
126
+ global $wpmem;
127
+ $wpmem->user->logout( $redirect_to );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
  endif;
130
 
148
  * Handles user password change (not reset).
149
  *
150
  * @since 2.1.0
151
+ * @since 3.1.7 Now a wrapper for password_update() in WP_Members_Users Class.
152
  *
153
  * @global int $user_ID The WordPress user ID.
154
  *
155
  * @return string The value for $wpmem->regchk
156
  */
157
  function wpmem_change_password() {
158
+ global $wpmem;
159
+ return $wpmem->user->password_update( 'change' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
  endif;
162
 
166
  * Resets a forgotten password.
167
  *
168
  * @since 2.1.0
169
+ * @since 3.1.7 Now a wrapper for password_update() in WP_Members_Users Class.
170
  *
171
  * @global object $wpmem The WP-Members object class.
172
  *
173
  * @return string The value for $wpmem->regchk
174
  */
175
  function wpmem_reset_password() {
 
176
  global $wpmem;
177
+ return $wpmem->user->password_update( 'reset' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
  endif;
180
 
242
  // Get any meta fields that should be excluded.
243
  $exclude = wpmem_get_excluded_meta( 'register' );
244
 
245
+ foreach ( wpmem_fields( 'wp_validate' ) as $meta_key => $field ) {
246
  $is_error = false;
247
  if ( $field['required'] && $meta_key != 'user_email' && ! in_array( $meta_key, $exclude ) ) {
248
  if ( ( $field['type'] == 'checkbox' || $field['type'] == 'multicheckbox' || $field['type'] == 'multiselect' || $field['type'] == 'radio' ) && ( ! isset( $_POST[ $meta_key ] ) ) ) {
273
  function wpmem_wp_reg_finalize( $user_id ) {
274
 
275
  global $wpmem;
276
+ // Is this WP's native registration? Checks the native submit button.
277
  $is_native = ( isset( $_POST['wp-submit'] ) && $_POST['wp-submit'] == esc_attr( __( 'Register' ) ) ) ? true : false;
278
+ // Is this a Users > Add New process? Checks the post action.
279
  $is_add_new = ( isset( $_POST['action'] ) && $_POST['action'] == 'createuser' ) ? true : false;
280
+ // Is this a WooCommerce checkout registration? Checks for WC fields.
281
  $is_woo = ( isset( $_POST['woocommerce_checkout_place_order'] ) || isset( $_POST['woocommerce-register-nonce'] ) ) ? true : false;
282
  if ( $is_native || $is_add_new || $is_woo ) {
283
  // Get any excluded meta fields.
284
  $exclude = wpmem_get_excluded_meta( 'register' );
285
+ foreach ( wpmem_fields( 'wp_finalize' ) as $meta_key => $field ) {
286
  if ( isset( $_POST[ $meta_key ] ) && ! in_array( $meta_key, $exclude ) && 'file' != $field['type'] && 'image' != $field['type'] ) {
287
  if ( 'multiselect' == $field['type'] || 'multicheckbox' == $field['type'] ) {
288
  $data = implode( $field['delimiter'], $_POST[ $meta_key ] );
292
  update_user_meta( $user_id, $meta_key, sanitize_text_field( $data ) );
293
  }
294
  }
295
+ }
296
+
297
+ // If this is Users > Add New.
298
+ if ( is_admin() && $is_add_new ) {
299
  // If moderated registration and activate is checked, set active flags.
300
+ if ( 1 == $wpmem->mod_reg && isset( $_POST['activate_user'] ) ) {
301
  update_user_meta( $user_id, 'active', 1 );
302
  wpmem_set_user_status( $user_id, 0 );
303
  }
304
  }
305
+
306
  return;
307
  }
308
 
405
  return;
406
  }
407
 
408
+
409
+ /**
410
+ * Adds the successful registration message on the login page if reg_nonce validates.
411
+ *
412
+ * @since 3.1.7
413
+ *
414
+ * @param string $content
415
+ * @return string $content
416
+ */
417
+ function wpmem_reg_securify( $content ) {
418
+ global $wpmem, $wpmem_themsg;
419
+ $nonce = wpmem_get( 'reg_nonce', false, 'get' );
420
+ if ( $nonce && wp_verify_nonce( $nonce, 'register_redirect' ) ) {
421
+ $content = wpmem_inc_regmessage( 'success', $wpmem_themsg );
422
+ $content = $content . wpmem_inc_login();
423
+ }
424
+ return $content;
425
+ }
426
+
427
+
428
+ /**
429
+ * Enqueues the admin javascript and css files.
430
+ *
431
+ * Replaces wpmem_admin_enqueue_scripts().
432
+ * Only loads the js and css on admin screens that use them.
433
+ *
434
+ * @since 3.1.7
435
+ *
436
+ * @param str $hook The admin screen hook being loaded.
437
+ */
438
+ function wpmem_dashboard_enqueue_scripts( $hook ) {
439
+ if ( $hook == 'edit.php' || $hook == 'settings_page_wpmem-settings' ) {
440
+ wp_enqueue_style( 'wpmem-admin', WPMEM_DIR . 'admin/css/admin.css', '', WPMEM_VERSION );
441
+ }
442
+ if ( $hook == 'settings_page_wpmem-settings' ) {
443
+ wp_enqueue_script( 'wpmem-admin', WPMEM_DIR . 'admin/js/admin.js', '', WPMEM_VERSION );
444
+ }
445
+ }
446
+
447
  // End of file.
inc/deprecated.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP-Members Deprecated Functions
4
+ *
5
+ * These functions have been deprecated and are now obsolete.
6
+ * Use alternative functions as these will be removed in a
7
+ * future release.
8
+ *
9
+ * This file is part of the WP-Members plugin by Chad Butler
10
+ * You can find out more about this plugin at http://rocketgeek.com
11
+ * Copyright (c) 2006-2017 Chad Butler
12
+ * WP-Members(tm) is a trademark of butlerblog.com
13
+ *
14
+ * @package WP-Members
15
+ * @author Chad Butler
16
+ * @copyright 2006-2017
17
+ */
18
+
19
+
20
+ if ( ! function_exists( 'wpmem_block' ) ):
21
+ /**
22
+ * Determines if content is blocked.
23
+ *
24
+ * @since 2.6.0
25
+ * @since 3.0.0 Now a wrapper for $wpmem->is_blocked().
26
+ * @deprecated 3.1.1 Use wpmem_is_blocked() instead.
27
+ *
28
+ * @global object $wpmem The WP-Members object class.
29
+ *
30
+ * @return bool $block true if content is blocked, false otherwise.
31
+ */
32
+ function wpmem_block() {
33
+ wpmem_write_log( "wpmem_block() is deprecated as of WP-Members 3.1.1, use wpmem_is_blocked() instead" );
34
+ global $wpmem;
35
+ return $wpmem->is_blocked();
36
+ }
37
+ endif;
38
+
39
+ if ( ! function_exists( 'wpmem_inc_sidebar' ) ):
40
+ /**
41
+ * Displays the sidebar.
42
+ *
43
+ * This function is a wrapper for wpmem_do_sidebar().
44
+ *
45
+ * @since 2.0.0
46
+ * @deprecated Unknown
47
+ */
48
+ function wpmem_inc_sidebar() {
49
+ wpmem_write_log( "WP-Members function wpmem_inc_sidebar() is deprecated. No alternative function exists" );
50
+ /**
51
+ * Load the sidebar functions.
52
+ */
53
+ include_once( WPMEM_PATH . 'inc/sidebar.php' );
54
+ // Render the sidebar.
55
+ wpmem_do_sidebar();
56
+ }
57
+ endif;
58
+
59
+ if ( ! function_exists( 'wpmem_selected' ) ):
60
+ /**
61
+ * Determines if a form field is selected (i.e. lists & checkboxes).
62
+ *
63
+ * @since 0.1.0
64
+ * @deprecated 3.1.0 Use selected() or checked() instead.
65
+ *
66
+ * @param string $value
67
+ * @param string $valtochk
68
+ * @param string $type
69
+ * @return string $issame
70
+ */
71
+ function wpmem_selected( $value, $valtochk, $type = null ) {
72
+ wpmem_write_log( "wpmem_selected() is deprecated as of WP-Members 3.1.0. Use selected() or checked() instead" );
73
+ $issame = ( $type == 'select' ) ? ' selected' : ' checked';
74
+ return ( $value == $valtochk ) ? $issame : '';
75
+ }
76
+ endif;
77
+
78
+ if ( ! function_exists( 'wpmem_chk_qstr' ) ):
79
+ /**
80
+ * Checks querystrings.
81
+ *
82
+ * @since 2.0.0
83
+ * @deprecated 3.1.0 Use add_query_arg() instead.
84
+ *
85
+ * @param string $url
86
+ * @return string $return_url
87
+ */
88
+ function wpmem_chk_qstr( $url = null ) {
89
+ wpmem_write_log( "wpmem_chk_qstr() is deprecated as of WP-Members 3.1.0. Use add_query_arg() instead" );
90
+ $permalink = get_option( 'permalink_structure' );
91
+ if ( ! $permalink ) {
92
+ $url = ( ! $url ) ? get_option( 'home' ) . "/?" . $_SERVER['QUERY_STRING'] : $url;
93
+ $return_url = $url . "&";
94
+ } else {
95
+ $url = ( ! $url ) ? get_permalink() : $url;
96
+ $return_url = $url . "?";
97
+ }
98
+ return $return_url;
99
+ }
100
+ endif;
101
+
102
+ if ( ! function_exists( 'wpmem_shortcode' ) ):
103
+ /**
104
+ * Executes various shortcodes.
105
+ *
106
+ * This function executes shortcodes for pages (settings, register, login, user-list,
107
+ * and tos pages), as well as login status and field attributes when the wp-members tag
108
+ * is used. Also executes shortcodes for login status with the wpmem_logged_in tags
109
+ * and fields when the wpmem_field tags are used.
110
+ *
111
+ * @since 2.4.0
112
+ * @deprecated 3.1.2
113
+ *
114
+ * @global object $wpmem The WP_Members object.
115
+ *
116
+ * @param array $attr {
117
+ * The shortcode attributes.
118
+ *
119
+ * @type string $page
120
+ * @type string $url
121
+ * @type string $status
122
+ * @type string $msg
123
+ * @type string $field
124
+ * @type int $id
125
+ * }
126
+ * @param string $content
127
+ * @param string $tag
128
+ * @return string Returns the result of wpmem_do_sc_pages|wpmem_list_users|wpmem_sc_expmessage|$content.
129
+ */
130
+ function wpmem_shortcode( $attr, $content = null, $tag = 'wp-members' ) {
131
+
132
+ $error = "wpmem_shortcode() is deprecated as of WP-Members 3.1.2. The [wp-members] shortcode tag should be replaced. ";
133
+ $error.= 'See replacement shortcodes: http://rkt.bz/logsc ';
134
+ $error.= "post ID: " . get_the_ID() . " ";
135
+ $error.= "page url: " . wpmem_current_url();
136
+ wpmem_write_log( $error );
137
+
138
+ global $wpmem;
139
+
140
+ // Set all default attributes to false.
141
+ $defaults = array(
142
+ 'page' => false,
143
+ 'redirect_to' => null,
144
+ 'url' => false,
145
+ 'status' => false,
146
+ 'msg' => false,
147
+ 'field' => false,
148
+ 'id' => false,
149
+ 'underscores' => 'off',
150
+ );
151
+
152
+ // Merge defaults with $attr.
153
+ $atts = shortcode_atts( $defaults, $attr, $tag );
154
+
155
+ // Handles the 'page' attribute.
156
+ if ( $atts['page'] ) {
157
+ if ( $atts['page'] == 'user-list' ) {
158
+ if ( function_exists( 'wpmem_list_users' ) ) {
159
+ $content = do_shortcode( wpmem_list_users( $attr, $content ) );
160
+ }
161
+ } elseif ( $atts['page'] == 'tos' ) {
162
+ return $atts['url'];
163
+ } else {
164
+ $content = do_shortcode( wpmem_do_sc_pages( $atts, $content, $tag ) );
165
+ }
166
+
167
+ // Resolve any texturize issues.
168
+ if ( strstr( $content, '[wpmem_txt]' ) ) {
169
+ // Fixes the wptexturize.
170
+ remove_filter( 'the_content', 'wpautop' );
171
+ remove_filter( 'the_content', 'wptexturize' );
172
+ add_filter( 'the_content', 'wpmem_texturize', 999 );
173
+ }
174
+ return $content;
175
+ }
176
+
177
+ // Handles the 'status' attribute.
178
+ if ( ( $atts['status'] ) || $tag == 'wpmem_logged_in' ) {
179
+ return wpmem_sc_logged_in( $atts, $content, $tag );
180
+ }
181
+
182
+ // Handles the 'field' attribute.
183
+ if ( $atts['field'] || $tag == 'wpmem_field' ) {
184
+ return wpmem_sc_fields( $atts, $content, $tag );
185
+ }
186
+
187
+ }
188
+ endif;
inc/dialogs.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions Included:
17
  * - wpmem_inc_loginfailed
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions Included:
17
  * - wpmem_inc_loginfailed
inc/email.php CHANGED
@@ -6,13 +6,13 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Email Functions
14
  * @author Chad Butler
15
- * @copyright 2006-2016
16
  *
17
  * Functions Included:
18
  * - wpmem_inc_regemail
@@ -47,7 +47,7 @@ function wpmem_inc_regemail( $user_id, $password, $toggle, $wpmem_fields = null,
47
  global $wpmem;
48
 
49
  // Handle backward compatibility for customizations that may call the email function directly.
50
- $wpmem_fields = wpmem_fields();
51
 
52
  /*
53
  * Determine which email is being sent.
@@ -273,12 +273,14 @@ function wpmem_inc_regemail( $user_id, $password, $toggle, $wpmem_fields = null,
273
  // Append footer if needed.
274
  $arr['body'] = ( $arr['add_footer'] ) ? $arr['body'] . "\r\n" . $foot : $arr['body'];
275
 
276
- // Apply from and from name email filters.
 
277
  add_filter( 'wp_mail_from', 'wpmem_mail_from' );
278
  add_filter( 'wp_mail_from_name', 'wpmem_mail_from_name' );
279
 
280
  // Send the message.
281
  wp_mail( $arr['user_email'], stripslashes( $arr['subj'] ), stripslashes( $arr['body'] ), $arr['headers'] );
 
282
 
283
  }
284
 
@@ -306,7 +308,7 @@ function wpmem_notify_admin( $user_id, $wpmem_fields = null, $field_data = null
306
  global $wpmem;
307
 
308
  // Handle backward compatibility for customizations that may call the email function directly.
309
- $wpmem_fields = wpmem_fields();
310
 
311
  // WP default user fields.
312
  $wp_user_fields = array(
@@ -357,7 +359,8 @@ function wpmem_notify_admin( $user_id, $wpmem_fields = null, $field_data = null
357
  } else {
358
  $val = ( is_array( $field_data ) ) ? esc_html( $field_data[ $meta_key ] ) : esc_html( get_user_meta( $user_id, $meta_key, true ) );
359
  }
360
- $field_arr[ $field['label'] ] = $val;
 
361
  }
362
  }
363
  }
@@ -370,11 +373,6 @@ function wpmem_notify_admin( $user_id, $wpmem_fields = null, $field_data = null
370
  /** This filter is documented in email.php */
371
  $arr['headers'] = apply_filters( 'wpmem_email_headers', $default_header, 'admin' );
372
 
373
- // Handle backward compatibility for customizations that may call the email function directly.
374
- if ( ! $wpmem_fields ) {
375
- $wpmem_fields = wpmem_fields();
376
- }
377
-
378
  /**
379
  * Filters the address the admin notification is sent to.
380
  *
@@ -407,7 +405,9 @@ function wpmem_notify_admin( $user_id, $wpmem_fields = null, $field_data = null
407
  // Split field_arr into field_str.
408
  $field_str = '';
409
  foreach ( $arr['field_arr'] as $key => $val ) {
410
- $field_str.= $key . ': ' . $val . "\r\n";
 
 
411
  }
412
 
413
  // Get the email footer if needed.
@@ -472,18 +472,26 @@ function wpmem_notify_admin( $user_id, $wpmem_fields = null, $field_data = null
472
  /**
473
  * Filters the admin notification email.
474
  *
 
 
 
 
 
 
475
  * @since 2.8.2
476
  *
477
  * @param string $arr['body'] The admin notification email body.
478
  */
479
  $arr['body'] = apply_filters( 'wpmem_email_notify', $arr['body'] );
480
 
 
481
  // Apply from and from name email filters.
482
  add_filter( 'wp_mail_from', 'wpmem_mail_from' );
483
  add_filter( 'wp_mail_from_name', 'wpmem_mail_from_name' );
484
 
485
  // Send the message.
486
  wp_mail( $arr['admin_email'], stripslashes( $arr['subj'] ), stripslashes( $arr['body'] ), $arr['headers'] );
 
487
  }
488
  }
489
  endif;
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Email Functions
14
  * @author Chad Butler
15
+ * @copyright 2006-2017
16
  *
17
  * Functions Included:
18
  * - wpmem_inc_regemail
47
  global $wpmem;
48
 
49
  // Handle backward compatibility for customizations that may call the email function directly.
50
+ $wpmem_fields = wpmem_fields( $toggle );
51
 
52
  /*
53
  * Determine which email is being sent.
273
  // Append footer if needed.
274
  $arr['body'] = ( $arr['add_footer'] ) ? $arr['body'] . "\r\n" . $foot : $arr['body'];
275
 
276
+ // @todo The remainder is slated to be moved to an "email send" function.
277
+ // Apply WP's "from" and "from name" email filters.
278
  add_filter( 'wp_mail_from', 'wpmem_mail_from' );
279
  add_filter( 'wp_mail_from_name', 'wpmem_mail_from_name' );
280
 
281
  // Send the message.
282
  wp_mail( $arr['user_email'], stripslashes( $arr['subj'] ), stripslashes( $arr['body'] ), $arr['headers'] );
283
+ // @todo End of slated for move.
284
 
285
  }
286
 
308
  global $wpmem;
309
 
310
  // Handle backward compatibility for customizations that may call the email function directly.
311
+ $wpmem_fields = wpmem_fields( 'admin_notify' );
312
 
313
  // WP default user fields.
314
  $wp_user_fields = array(
359
  } else {
360
  $val = ( is_array( $field_data ) ) ? esc_html( $field_data[ $meta_key ] ) : esc_html( get_user_meta( $user_id, $meta_key, true ) );
361
  }
362
+ // $field_arr[ $field['label'] ] = $val; // @todo Consider (1) if this should be implemented, and (2) if it should be done here or location "B".
363
+ $field_arr[ __( $field['label'], 'wp-members' ) ] = $val;
364
  }
365
  }
366
  }
373
  /** This filter is documented in email.php */
374
  $arr['headers'] = apply_filters( 'wpmem_email_headers', $default_header, 'admin' );
375
 
 
 
 
 
 
376
  /**
377
  * Filters the address the admin notification is sent to.
378
  *
405
  // Split field_arr into field_str.
406
  $field_str = '';
407
  foreach ( $arr['field_arr'] as $key => $val ) {
408
+ $field_str.= $key . ': ' . $val . "\r\n";
409
+ // @todo Location "B" to to label translation. Could be as follows:
410
+ // $field_str.= __( $key, 'wp-members' ) . ": " . $val . "\r\n";
411
  }
412
 
413
  // Get the email footer if needed.
472
  /**
473
  * Filters the admin notification email.
474
  *
475
+ * This is the last chance to filter the message body. At this point
476
+ * it is just the text that will be in the message.
477
+ * @todo Consider deprecating this filter as it could be accomplished
478
+ * by the wp_mail filter, or a universal filter could be added
479
+ * to the new email send function.
480
+ *
481
  * @since 2.8.2
482
  *
483
  * @param string $arr['body'] The admin notification email body.
484
  */
485
  $arr['body'] = apply_filters( 'wpmem_email_notify', $arr['body'] );
486
 
487
+ // @todo The remainder is slated to be moved to an "email send" function.
488
  // Apply from and from name email filters.
489
  add_filter( 'wp_mail_from', 'wpmem_mail_from' );
490
  add_filter( 'wp_mail_from_name', 'wpmem_mail_from_name' );
491
 
492
  // Send the message.
493
  wp_mail( $arr['admin_email'], stripslashes( $arr['subj'] ), stripslashes( $arr['body'] ), $arr['headers'] );
494
+ // @todo End of slated to be moved.
495
  }
496
  }
497
  endif;
inc/forms.php CHANGED
@@ -6,13 +6,13 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Form Building Functions
14
  * @author Chad Butler
15
- * @copyright 2006-2016
16
  *
17
  * Functions Included:
18
  * - wpmem_inc_login
@@ -57,7 +57,7 @@ function wpmem_inc_login( $page = "page", $redirect_to = null, $show = 'show' )
57
  // This shown above blocked content.
58
  $msg = $wpmem->get_text( 'restricted_msg' );
59
  $msg = ( $dialogs['restricted_msg'] == $msg ) ? $msg : __( stripslashes( $dialogs['restricted_msg'] ), 'wp-members' );
60
- $str = "<p>$msg</p>";
61
 
62
  /**
63
  * Filter the post restricted message.
@@ -265,6 +265,7 @@ if ( ! function_exists( 'wpmem_login_form' ) ):
265
  * Builds the form used for login, change password, and reset password.
266
  *
267
  * @since 2.5.1
 
268
  *
269
  * @param string $page
270
  * @param array $arr {
@@ -290,251 +291,9 @@ if ( ! function_exists( 'wpmem_login_form' ) ):
290
  * @return string $form The HTML for the form as a string.
291
  */
292
  function wpmem_login_form( $page, $arr ) {
293
-
294
  global $wpmem;
295
-
296
- // set up default wrappers
297
- $defaults = array(
298
-
299
- // wrappers
300
- 'heading_before' => '<legend>',
301
- 'heading_after' => '</legend>',
302
- 'fieldset_before' => '<fieldset>',
303
- 'fieldset_after' => '</fieldset>',
304
- 'main_div_before' => '<div id="wpmem_login">',
305
- 'main_div_after' => '</div>',
306
- 'txt_before' => '[wpmem_txt]',
307
- 'txt_after' => '[/wpmem_txt]',
308
- 'row_before' => '',
309
- 'row_after' => '',
310
- 'buttons_before' => '<div class="button_div">',
311
- 'buttons_after' => '</div>',
312
- 'link_before' => '<div align="right" class="link-text">',
313
- 'link_after' => '</div>',
314
-
315
- // classes & ids
316
- 'form_id' => '',
317
- 'form_class' => 'form',
318
- 'button_id' => '',
319
- 'button_class' => 'buttons',
320
-
321
- // other
322
- 'strip_breaks' => true,
323
- 'wrap_inputs' => true,
324
- 'remember_check' => true,
325
- 'n' => "\n",
326
- 't' => "\t",
327
- 'redirect_to' => ( isset( $_REQUEST['redirect_to'] ) ) ? esc_url( $_REQUEST['redirect_to'] ) : ( ( isset( $arr['redirect_to'] ) ) ? $arr['redirect_to'] : get_permalink() ),
328
-
329
- );
330
-
331
- /**
332
- * Filter the default form arguments.
333
- *
334
- * This filter accepts an array of various elements to replace the form defaults. This
335
- * includes default tags, labels, text, and small items including various booleans.
336
- *
337
- * @since 2.9.0
338
- *
339
- * @param array An array of arguments to merge with defaults. Default null.
340
- * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
341
- */
342
- $args = apply_filters( 'wpmem_login_form_args', '', $arr['action'] );
343
-
344
- // Merge $args with defaults.
345
- $args = wp_parse_args( $args, $defaults );
346
-
347
- // Build the input rows.
348
- foreach ( $arr['inputs'] as $input ) {
349
- $label = '<label for="' . $input['tag'] . '">' . $input['name'] . '</label>';
350
- $field = wpmem_create_formfield( $input['tag'], $input['type'], '', '', $input['class'] );
351
- $field_before = ( $args['wrap_inputs'] ) ? '<div class="' . $input['div'] . '">' : '';
352
- $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
353
- $rows[] = array(
354
- 'row_before' => $args['row_before'],
355
- 'label' => $label,
356
- 'field_before' => $field_before,
357
- 'field' => $field,
358
- 'field_after' => $field_after,
359
- 'row_after' => $args['row_after'],
360
- );
361
- }
362
-
363
- /**
364
- * Filter the array of form rows.
365
- *
366
- * This filter receives an array of the main rows in the form, each array element being
367
- * an array of that particular row's pieces. This allows making changes to individual
368
- * parts of a row without needing to parse through a string of HTML.
369
- *
370
- * @since 2.9.0
371
- *
372
- * @param array $rows An array containing the form rows.
373
- * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
374
- */
375
- $rows = apply_filters( 'wpmem_login_form_rows', $rows, $arr['action'] );
376
-
377
- // Put the rows from the array into $form.
378
- $form = '';
379
- foreach ( $rows as $row_item ) {
380
- $row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
381
- $row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
382
- $row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
383
- $form.= $row;
384
- }
385
-
386
- // Build hidden fields, filter, and add to the form.
387
- $hidden = wpmem_create_formfield( 'redirect_to', 'hidden', $args['redirect_to'] ) . $args['n'];
388
- $hidden = $hidden . wpmem_create_formfield( 'a', 'hidden', $arr['action'] ) . $args['n'];
389
- $hidden = ( $arr['action'] != 'login' ) ? $hidden . wpmem_create_formfield( 'formsubmit', 'hidden', '1' ) : $hidden;
390
-
391
- /**
392
- * Filter the hidden field HTML.
393
- *
394
- * @since 2.9.0
395
- *
396
- * @param string $hidden The generated HTML of hidden fields.
397
- * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
398
- */
399
- $form = $form . apply_filters( 'wpmem_login_hidden_fields', $hidden, $arr['action'] );
400
-
401
- // Build the buttons, filter, and add to the form.
402
- if ( $arr['action'] == 'login' ) {
403
- $args['remember_check'] = ( $args['remember_check'] ) ? $args['t'] . wpmem_create_formfield( 'rememberme', 'checkbox', 'forever' ) . '&nbsp;' . '<label for="rememberme">' . $wpmem->get_text( 'remember_me' ) . '</label>&nbsp;&nbsp;' . $args['n'] : '';
404
- $buttons = $args['remember_check'] . $args['t'] . '<input type="submit" name="Submit" value="' . $arr['button_text'] . '" class="' . $args['button_class'] . '" />' . $args['n'];
405
- } else {
406
- $buttons = '<input type="submit" name="Submit" value="' . $arr['button_text'] . '" class="' . $args['button_class'] . '" />' . $args['n'];
407
- }
408
-
409
- /**
410
- * Filter the HTML for form buttons.
411
- *
412
- * The string includes the buttons, as well as the before/after wrapper elements.
413
- *
414
- * @since 2.9.0
415
- *
416
- * @param string $buttons The generated HTML of the form buttons.
417
- * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
418
- */
419
- $form = $form . apply_filters( 'wpmem_login_form_buttons', $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'], $arr['action'] );
420
-
421
- if ( ( $wpmem->user_pages['profile'] != null || $page == 'members' ) && $arr['action'] == 'login' ) {
422
-
423
- /**
424
- * Filters the forgot password link.
425
- *
426
- * @since 2.8.0
427
- *
428
- * @param string The forgot password link.
429
- */
430
- $link = apply_filters( 'wpmem_forgot_link', add_query_arg( 'a', 'pwdreset', $wpmem->user_pages['profile'] ) );
431
- $str = $wpmem->get_text( 'forgot_link_before' ) . '<a href="' . $link . '">' . $wpmem->get_text( 'forgot_link' ) . '</a>';
432
- /**
433
- * Filters the forgot password HTML.
434
- *
435
- * @since 2.9.0
436
- * @since 3.0.9 Added $link parameter.
437
- *
438
- * @param string $str The forgot password link HTML.
439
- * @param string $link The forgot password link.
440
- */
441
- $form = $form . $args['link_before'] . apply_filters( 'wpmem_forgot_link_str', $str, $link ) . $args['link_after'] . $args['n'];
442
-
443
- }
444
-
445
- if ( ( $wpmem->user_pages['register'] != null ) && $arr['action'] == 'login' ) {
446
-
447
- /**
448
- * Filters the link to the registration page.
449
- *
450
- * @since 2.8.0
451
- *
452
- * @param string The registration page link.
453
- */
454
- $link = apply_filters( 'wpmem_reg_link', $wpmem->user_pages['register'] );
455
- $str = $wpmem->get_text( 'register_link_before' ) . '<a href="' . $link . '">' . $wpmem->get_text( 'register_link' ) . '</a>';
456
- /**
457
- * Filters the register link HTML.
458
- *
459
- * @since 2.9.0
460
- * @since 3.0.9 Added $link parameter.
461
- *
462
- * @param string $str The register link HTML.
463
- * @param string $link The register link.
464
- */
465
- $form = $form . $args['link_before'] . apply_filters( 'wpmem_reg_link_str', $str, $link ) . $args['link_after'] . $args['n'];
466
-
467
- }
468
-
469
- if ( ( $wpmem->user_pages['profile'] != null || $page == 'members' ) && $arr['action'] == 'pwdreset' ) {
470
-
471
- /**
472
- * Filters the forgot username link.
473
- *
474
- * @since 3.0.9
475
- *
476
- * @param string The forgot username link.
477
- */
478
- $link = apply_filters( 'wpmem_username_link', add_query_arg( 'a', 'getusername', $wpmem->user_pages['profile'] ) );
479
- $str = $wpmem->get_text( 'username_link_before' ) . '<a href="' . $link . '">' . $wpmem->get_text( 'username_link' ) . '</a>';
480
- /**
481
- * Filters the forgot username link HTML.
482
- *
483
- * @since 3.0.9
484
- *
485
- * @param string $str The forgot username link HTML.
486
- * @param string $link The forgot username link.
487
- */
488
- $form = $form . $args['link_before'] . apply_filters( 'wpmem_username_link_str', $str, $link ) . $args['link_after'] . $args['n'];
489
-
490
- }
491
-
492
- // Apply the heading.
493
- $form = $args['heading_before'] . $arr['heading'] . $args['heading_after'] . $args['n'] . $form;
494
-
495
- // Apply fieldset wrapper.
496
- $form = $args['fieldset_before'] . $args['n'] . $form . $args['fieldset_after'] . $args['n'];
497
-
498
- // Apply form wrapper.
499
- $form = '<form action="' . get_permalink() . '" method="POST" id="' . $args['form_id'] . '" class="' . $args['form_class'] . '">' . $args['n'] . $form . '</form>';
500
-
501
- // Apply anchor.
502
- $form = '<a name="' . $arr['action'] . '"></a>' . $args['n'] . $form;
503
-
504
- // Apply main wrapper.
505
- $form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'];
506
-
507
- // Apply wpmem_txt wrapper.
508
- $form = $args['txt_before'] . $form . $args['txt_after'];
509
-
510
- // Remove line breaks.
511
- $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
512
-
513
- /**
514
- * Filter the generated HTML of the entire form.
515
- *
516
- * @since 2.7.4
517
- *
518
- * @param string $form The HTML of the final generated form.
519
- * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
520
- */
521
- $form = apply_filters( 'wpmem_login_form', $form, $arr['action'] );
522
-
523
- /**
524
- * Filter before the form.
525
- *
526
- * This rarely used filter allows you to stick any string onto the front of
527
- * the generated form.
528
- *
529
- * @since 2.7.4
530
- *
531
- * @param string $str The HTML to add before the form. Default null.
532
- * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange|getusername.
533
- */
534
- $form = apply_filters( 'wpmem_login_form_before', '', $arr['action'] ) . $form;
535
-
536
- return $form;
537
- } // End wpmem_login_form.
538
  endif;
539
 
540
 
@@ -545,550 +304,16 @@ if ( ! function_exists( 'wpmem_inc_registration' ) ):
545
  * Outputs the form for new user registration and existing user edits.
546
  *
547
  * @since 2.5.1
 
548
  *
549
  * @global object $wpmem The WP_Members object.
550
- * @global string $wpmem_regchk Used to determine if the form is in an error state.
551
- * @global array $userdata Used to get the user's registration data if they are logged in (user profile edit).
552
  * @param string $tag (optional) Toggles between new registration ('new') and user profile edit ('edit').
553
  * @param string $heading (optional) The heading text for the form, null (default) for new registration.
554
  * @return string $form The HTML for the entire form as a string.
555
  */
556
  function wpmem_inc_registration( $tag = 'new', $heading = '', $redirect_to = null ) {
557
-
558
- global $wpmem, $wpmem_regchk, $userdata;
559
-
560
- // Set up default wrappers.
561
- $defaults = array(
562
-
563
- // Wrappers.
564
- 'heading_before' => '<legend>',
565
- 'heading_after' => '</legend>',
566
- 'fieldset_before' => '<fieldset>',
567
- 'fieldset_after' => '</fieldset>',
568
- 'main_div_before' => '<div id="wpmem_reg">',
569
- 'main_div_after' => '</div>',
570
- 'txt_before' => '[wpmem_txt]',
571
- 'txt_after' => '[/wpmem_txt]',
572
- 'row_before' => '',
573
- 'row_after' => '',
574
- 'buttons_before' => '<div class="button_div">',
575
- 'buttons_after' => '</div>',
576
-
577
- // Classes & ids.
578
- 'form_id' => '',
579
- 'form_class' => 'form',
580
- 'button_id' => '',
581
- 'button_class' => 'buttons',
582
-
583
- // Required field tags and text.
584
- 'req_mark' => $wpmem->get_text( 'register_req_mark' ),
585
- 'req_label' => $wpmem->get_text( 'register_required' ),
586
- 'req_label_before' => '<div class="req-text">',
587
- 'req_label_after' => '</div>',
588
-
589
- // Buttons.
590
- 'show_clear_form' => false,
591
- 'clear_form' => $wpmem->get_text( 'register_clear' ),
592
- 'submit_register' => $wpmem->get_text( 'register_submit' ),
593
- 'submit_update' => $wpmem->get_text( 'profile_submit' ),
594
-
595
- // Other.
596
- 'strip_breaks' => true,
597
- 'use_nonce' => false,
598
- 'wrap_inputs' => true,
599
- 'n' => "\n",
600
- 't' => "\t",
601
-
602
- );
603
-
604
- /**
605
- * Filter the default form arguments.
606
- *
607
- * This filter accepts an array of various elements to replace the form defaults. This
608
- * includes default tags, labels, text, and small items including various booleans.
609
- *
610
- * @since 2.9.0
611
- *
612
- * @param array An array of arguments to merge with defaults. Default null.
613
- * @param string $tag Toggle new registration or profile update. new|edit.
614
- */
615
- $args = apply_filters( 'wpmem_register_form_args', '', $tag );
616
-
617
- // Merge $args with defaults.
618
- $args = wp_parse_args( $args, $defaults );
619
-
620
- // Username is editable if new reg, otherwise user profile is not.
621
- if ( $tag == 'edit' ) {
622
- // This is the User Profile edit - username is not editable.
623
- $val = $userdata->user_login;
624
- $label = '<label for="user_login" class="text">' . $wpmem->get_text( 'profile_username' ) . '</label>';
625
- $input = '<p class="noinput">' . $val . '</p>';
626
- $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
627
- $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
628
- } else {
629
- // This is a new registration.
630
- $val = ( isset( $_POST['user_login'] ) ) ? stripslashes( $_POST['user_login'] ) : '';
631
- $label = '<label for="user_login" class="text">' . $wpmem->get_text( 'register_username' ) . $args['req_mark'] . '</label>';
632
- $input = wpmem_form_field( array(
633
- 'name' => 'user_login',
634
- 'type' => 'text',
635
- 'value' => $val,
636
- 'compare' => '',
637
- 'required' => true,
638
- ) );
639
-
640
- }
641
- $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
642
- $field_after = ( $args['wrap_inputs'] ) ? '</div>': '';
643
-
644
- // Add the username row to the array.
645
- $rows['username'] = array(
646
- 'meta' => 'username',
647
- 'type' => 'text',
648
- 'value' => $val,
649
- 'label_text' => $wpmem->get_text( 'register_username' ),
650
- 'row_before' => $args['row_before'],
651
- 'label' => $label,
652
- 'field_before' => $field_before,
653
- 'field' => $input,
654
- 'field_after' => $field_after,
655
- 'row_after' => $args['row_after'],
656
- );
657
-
658
- /**
659
- * Filter the array of form fields.
660
- *
661
- * The form fields are stored in the WP options table as wpmembers_fields. This
662
- * filter can filter that array after the option is retreived before the fields
663
- * are parsed. This allows you to change the fields that may be used in the form
664
- * on the fly.
665
- *
666
- * @since 2.9.0
667
- *
668
- * @param array The array of form fields.
669
- * @param string $tag Toggle new registration or profile update. new|edit.
670
- */
671
- $wpmem_fields = apply_filters( 'wpmem_register_fields_arr', wpmem_fields(), $tag );
672
- //$wpmem_fields = wpmem_verify_fields( $wpmem_fields );
673
-
674
- $hidden = '';
675
-
676
- // Loop through the remaining fields.
677
- foreach ( $wpmem_fields as $meta_key => $field ) {
678
-
679
- // Start with a clean row.
680
- $val = ''; $label = ''; $input = ''; $field_before = ''; $field_after = '';
681
-
682
- // Skips user selected passwords for profile update.
683
- $pass_arr = array( 'password', 'confirm_password', 'password_confirm' );
684
- $do_row = ( $tag == 'edit' && in_array( $meta_key, $pass_arr ) ) ? false : true;
685
-
686
- // Skips tos, makes tos field hidden on user edit page, unless they haven't got a value for tos.
687
- if ( $meta_key == 'tos' && $tag == 'edit' && ( get_user_meta( $userdata->ID, 'tos', true ) ) ) {
688
- $do_row = false;
689
- $hidden_tos = wpmem_form_field( array(
690
- 'name' => $meta_key,
691
- 'type' => 'hidden',
692
- 'value' => get_user_meta( $userdata->ID, 'tos', true )
693
- ) );
694
- }
695
-
696
- // Handle hidden fields
697
- if ( 'hidden' == $field['type'] ) {
698
- $do_row = false;
699
- $hidden.= wpmem_form_field( array(
700
- 'name' => $meta_key,
701
- 'type' => $field['type'],
702
- 'value' => $field['value'],
703
- 'compare' => $valtochk,
704
- //'class' => ( $class ) ? $class : 'textbox',
705
- 'required' => $field['required'],
706
- ) );
707
- }
708
-
709
- // If the field is set to display and we aren't skipping, construct the row.
710
- if ( $do_row && $field['register'] ) {
711
-
712
- // Label for all but TOS.
713
- if ( $meta_key != 'tos' ) {
714
-
715
- $class = ( $field['type'] == 'password' || $field['type'] == 'email' || $field['type'] == 'url' ) ? 'text' : $field['type'];
716
-
717
- $label = '<label for="' . $meta_key . '" class="' . $class . '">' . __( $field['label'], 'wp-members' );
718
- $label = ( $field['required'] ) ? $label . $args['req_mark'] : $label;
719
- $label = $label . '</label>';
720
-
721
- }
722
-
723
- // Gets the field value for both edit profile and submitted reg w/ error.
724
- if ( ( $tag == 'edit' ) && ( $wpmem_regchk != 'updaterr' ) ) {
725
-
726
- switch ( $meta_key ) {
727
- case( 'description' ):
728
- $val = htmlspecialchars( get_user_meta( $userdata->ID, 'description', 'true' ) );
729
- break;
730
-
731
- case 'user_email':
732
- case 'confirm_email':
733
- $val = sanitize_email( $userdata->user_email );
734
- break;
735
-
736
- case 'user_url':
737
- $val = esc_url( $userdata->user_url );
738
- break;
739
-
740
- case 'display_name':
741
- $val = sanitize_text_field( $userdata->display_name );
742
- break;
743
-
744
- default:
745
- $val = sanitize_text_field( get_user_meta( $userdata->ID, $meta_key, 'true' ) );
746
- break;
747
- }
748
-
749
- } else {
750
- if ( 'file' == $field['type'] ) {
751
- $val = ( isset( $_FILES[ $meta_key ]['name'] ) ) ? $_FILES[ $meta_key ]['name'] : '' ;
752
- } else {
753
- $val = ( isset( $_POST[ $meta_key ] ) ) ? $_POST[ $meta_key ] : '';
754
- }
755
- }
756
-
757
- // Does the tos field.
758
- if ( $meta_key == 'tos' ) {
759
-
760
- $val = ( isset( $_POST[ $meta_key ] ) ) ? $_POST[ $meta_key ] : '';
761
-
762
- // Should be checked by default? and only if form hasn't been submitted.
763
- $val = ( ! $_POST && $field['checked_default'] ) ? $field['checked_value'] : $val;
764
- $input = wpmem_form_field( array(
765
- 'name' => $meta_key,
766
- 'type' => $field['type'],
767
- 'value' => $field['checked_value'],
768
- 'compare' => $val
769
- ) );
770
- $input = ( $field['required'] ) ? $input . $args['req_mark'] : $input;
771
-
772
- // Determine if TOS is a WP page or not.
773
- $tos_content = stripslashes( get_option( 'wpmembers_tos' ) );
774
- if ( has_shortcode( $tos_content, 'wp-members' ) || has_shortcode( $tos_content, 'wpmem_tos' ) ) {
775
- $link = do_shortcode( $tos_content );
776
- $tos_pop = '<a href="' . $link . '" target="_blank">';
777
- } else {
778
- $tos_pop = "<a href=\"#\" onClick=\"window.open('" . WPMEM_DIR . "/wp-members-tos.php','mywindow');\">";
779
- }
780
-
781
- /**
782
- * Filter the TOS link text.
783
- *
784
- * @since 2.7.5
785
- *
786
- * @param string The link text.
787
- * @param string $tag Toggle new registration or profile update. new|edit.
788
- */
789
- $input.= apply_filters( 'wpmem_tos_link_txt', sprintf( $wpmem->get_text( 'register_tos' ), $tos_pop, '</a>' ), $tag );
790
-
791
- // In previous versions, the div class would end up being the same as the row before.
792
- $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
793
- $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
794
-
795
- } else {
796
-
797
- // For checkboxes.
798
- if ( $field['type'] == 'checkbox' ) {
799
- $valtochk = $val;
800
- $val = $field['checked_value'];
801
- // if it should it be checked by default (& only if form not submitted), then override above...
802
- if ( $field['checked_default'] && ( ! $_POST && $tag != 'edit' ) ) { $val = $valtochk = $field['checked_value']; }
803
- }
804
-
805
- // For dropdown select.
806
- if ( $field['type'] == 'select' || $field['type'] == 'radio' || $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) {
807
- $valtochk = $val;
808
- $val = $field['values'];
809
- }
810
-
811
- if ( ! isset( $valtochk ) ) { $valtochk = ''; }
812
-
813
- if ( 'edit' == $tag && ( 'file' == $field['type'] || 'image' == $field['type'] ) ) {
814
-
815
- $attachment_url = wp_get_attachment_url( $val );
816
- $empty_file = '<span class="description">' . __( 'None' ) . '</span>';
817
- if ( 'file' == $field['type'] ) {
818
- $input = ( $attachment_url ) ? '<a href="' . $attachment_url . '">' . get_the_title( $val ) . '</a>' : $empty_file;
819
- } else {
820
- $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file;
821
- }
822
- // @todo - come up with a way to handle file updates - user profile form does not support multitype
823
- $input.= '<br />' . $wpmem->get_text( 'profile_upload' ) . '<br />';
824
- $input.= wpmem_form_field( array(
825
- 'name' => $meta_key,
826
- 'type' => $field['type'],
827
- 'value' => $val,
828
- 'compare' => $valtochk,
829
- ) );
830
-
831
- } else {
832
-
833
- // For all other input types.
834
- //$input = wpmem_create_formfield( $meta_key, $field['type'], $val, $valtochk );
835
- $formfield_args = array(
836
- 'name' => $meta_key,
837
- 'type' => $field['type'],
838
- 'value' => $val,
839
- 'compare' => $valtochk,
840
- //'class' => ( $class ) ? $class : 'textbox',
841
- 'required' => $field['required'],
842
- 'placeholder' => ( isset( $field['placeholder'] ) ) ? $field['placeholder'] : '',
843
- );
844
- if ( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) {
845
- $formfield_args['delimiter'] = $field['delimiter'];
846
- }
847
- $input = wpmem_form_field( $formfield_args );
848
-
849
- }
850
-
851
- // Determine input wrappers.
852
- $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_' . $class . '">' : '';
853
- $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
854
- }
855
-
856
- }
857
-
858
- // If the row is set to display, add the row to the form array.
859
- if ( $field['register'] ) {
860
-
861
- $values = '';
862
- if ( 'multicheckbox' == $field['type'] || 'select' == $field['type'] || 'multiselect' == $field['type'] || 'radio' == $field['type'] ) {
863
- $values = $val;
864
- $val = $valtochk;
865
- }
866
-
867
- $rows[ $meta_key ] = array(
868
- 'meta' => $meta_key,
869
- 'type' => $field['type'],
870
- 'value' => $val,
871
- 'values' => $values,
872
- 'label_text' => __( $field['label'], 'wp-members' ),
873
- 'row_before' => $args['row_before'],
874
- 'label' => $label,
875
- 'field_before' => $field_before,
876
- 'field' => $input,
877
- 'field_after' => $field_after,
878
- 'row_after' => $args['row_after'],
879
- );
880
- }
881
- }
882
-
883
- // If captcha is Really Simple CAPTCHA.
884
- if ( $wpmem->captcha == 2 && $tag != 'edit' ) {
885
- $row = wpmem_build_rs_captcha();
886
- $rows['captcha'] = array(
887
- 'meta' => '',
888
- 'type' => 'text',
889
- 'value' => '',
890
- 'values' => '',
891
- 'label_text' => $row['label_text'],
892
- 'row_before' => $args['row_before'],
893
- 'label' => $row['label'],
894
- 'field_before' => $field_before,
895
- 'field' => $row['field'],
896
- 'field_after' => $field_after,
897
- 'row_after' => $args['row_after'],
898
- );
899
- }
900
-
901
- /**
902
- * Filter the array of form rows.
903
- *
904
- * This filter receives an array of the main rows in the form, each array element being
905
- * an array of that particular row's pieces. This allows making changes to individual
906
- * parts of a row without needing to parse through a string of HTML.
907
- *
908
- * @since 2.9.0
909
- * @since 3.0.9 Added $rows['label_text'].
910
- * @since 3.1.0 Added $rows['key'].
911
- * @since 3.1.6 Deprecated $rows['order'].
912
- *
913
- * @param array $rows {
914
- * An array containing the form rows.
915
- *
916
- * @type string order Field display order. (deprecated as of 3.1.6)
917
- * @type string meta Field meta tag (not used for display).
918
- * @type string type Input field type (not used for display).
919
- * @type string value Input field value (not used for display).
920
- * @type string values Possible field values (dropdown, multiple select/check, radio).
921
- * @type string label_text Raw text for the label (not used for display).
922
- * @type string row_before Opening wrapper tag around the row.
923
- * @type string label Label tag.
924
- * @type string field_before Opening wrapper tag before the input tag.
925
- * @type string field The field input tag.
926
- * @type string field_after Closing wrapper tag around the input tag.
927
- * @type string row_after Closing wrapper tag around the row.
928
- * }
929
- * @param string $tag Toggle new registration or profile update. new|edit.
930
- */
931
- $rows = apply_filters( 'wpmem_register_form_rows', $rows, $tag );
932
-
933
- // Put the rows from the array into $form.
934
- $form = ''; $enctype = '';
935
- foreach ( $rows as $row_item ) {
936
- $enctype = ( $row_item['type'] == 'file' || $row_item['type'] == 'image' ) ? "multipart/form-data" : $enctype;
937
- $row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
938
- $row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
939
- $row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
940
- $form.= $row;
941
- }
942
-
943
- // Do recaptcha if enabled.
944
- if ( ( $wpmem->captcha == 1 || $wpmem->captcha == 3 ) && $tag != 'edit' ) { // don't show on edit page!
945
-
946
- // Get the captcha options.
947
- $wpmem_captcha = get_option( 'wpmembers_captcha' );
948
-
949
- // Start with a clean row.
950
- $row = '';
951
- $row = '<div class="clear"></div>';
952
- $row.= '<div align="right" class="captcha">' . wpmem_inc_recaptcha( $wpmem_captcha['recaptcha'] ) . '</div>';
953
-
954
- // Add the captcha row to the form.
955
- /**
956
- * Filter the HTML for the CAPTCHA row.
957
- *
958
- * @since 2.9.0
959
- *
960
- * @param string The HTML for the entire row (includes HTML tags plus reCAPTCHA).
961
- * @param string $tag Toggle new registration or profile update. new|edit.
962
- */
963
- $form.= apply_filters( 'wpmem_register_captcha_row', $args['row_before'] . $row . $args['row_after'], $tag );
964
- }
965
-
966
- // Create hidden fields.
967
- $var = ( $tag == 'edit' ) ? 'update' : 'register';
968
- $redirect_to = ( isset( $_REQUEST['redirect_to'] ) ) ? esc_url( $_REQUEST['redirect_to'] ) : ( ( $redirect_to ) ? $redirect_to : get_permalink() );
969
- $hidden .= '<input name="a" type="hidden" value="' . $var . '" />' . $args['n'];
970
- $hidden .= '<input name="wpmem_reg_page" type="hidden" value="' . get_permalink() . '" />' . $args['n'];
971
- if ( $redirect_to != get_permalink() ) {
972
- $hidden .= '<input name="redirect_to" type="hidden" value="' . $redirect_to . '" />' . $args['n'];
973
- }
974
- $hidden = ( isset( $hidden_tos ) ) ? $hidden . $hidden_tos . $args['n'] : $hidden;
975
-
976
- /**
977
- * Filter the hidden field HTML.
978
- *
979
- * @since 2.9.0
980
- *
981
- * @param string $hidden The generated HTML of hidden fields.
982
- * @param string $tag Toggle new registration or profile update. new|edit.
983
- */
984
- $hidden = apply_filters( 'wpmem_register_hidden_fields', $hidden, $tag );
985
-
986
- // Add the hidden fields to the form.
987
- $form.= $hidden;
988
-
989
- // Create buttons and wrapper.
990
- $button_text = ( $tag == 'edit' ) ? $args['submit_update'] : $args['submit_register'];
991
- $buttons = ( $args['show_clear_form'] ) ? '<input name="reset" type="reset" value="' . $args['clear_form'] . '" class="' . $args['button_class'] . '" /> ' . $args['n'] : '';
992
- $buttons.= '<input name="submit" type="submit" value="' . $button_text . '" class="' . $args['button_class'] . '" />' . $args['n'];
993
-
994
- /**
995
- * Filter the HTML for form buttons.
996
- *
997
- * The string passed through the filter includes the buttons, as well as the HTML wrapper elements.
998
- *
999
- * @since 2.9.0
1000
- *
1001
- * @param string $buttons The generated HTML of the form buttons.
1002
- * @param string $tag Toggle new registration or profile update. new|edit.
1003
- */
1004
- $buttons = apply_filters( 'wpmem_register_form_buttons', $buttons, $tag );
1005
-
1006
- // Add the buttons to the form.
1007
- $form.= $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'];
1008
-
1009
- // Add the required field notation to the bottom of the form.
1010
- $form.= $args['req_label_before'] . $args['req_label'] . $args['req_label_after'];
1011
-
1012
- // Apply the heading.
1013
- /**
1014
- * Filter the registration form heading.
1015
- *
1016
- * @since 2.8.2
1017
- *
1018
- * @param string $str
1019
- * @param string $tag Toggle new registration or profile update. new|edit.
1020
- */
1021
- $heading = ( !$heading ) ? apply_filters( 'wpmem_register_heading', $wpmem->get_text( 'register_heading' ), $tag ) : $heading;
1022
- $form = $args['heading_before'] . $heading . $args['heading_after'] . $args['n'] . $form;
1023
-
1024
- // Apply fieldset wrapper.
1025
- $form = $args['fieldset_before'] . $args['n'] . $form . $args['n'] . $args['fieldset_after'];
1026
-
1027
- // Apply attribution if enabled.
1028
- $form = $form . wpmem_inc_attribution();
1029
-
1030
- // Apply nonce.
1031
- $form = ( defined( 'WPMEM_USE_NONCE' ) || $args['use_nonce'] ) ? wp_nonce_field( 'wpmem-validate-submit', 'wpmem-form-submit' ) . $args['n'] . $form : $form;
1032
-
1033
- // Apply form wrapper.
1034
- $enctype = ( $enctype == 'multipart/form-data' ) ? ' enctype="multipart/form-data"' : '';
1035
- $post_to = get_permalink();
1036
- $form = '<form name="form" method="post"' . $enctype . ' action="' . $post_to . '" id="' . $args['form_id'] . '" class="' . $args['form_class'] . '">' . $args['n'] . $form . $args['n'] . '</form>';
1037
-
1038
- // Apply anchor.
1039
- $form = '<a name="register"></a>' . $args['n'] . $form;
1040
-
1041
- // Apply main div wrapper.
1042
- $form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'] . $args['n'];
1043
-
1044
- // Apply wpmem_txt wrapper.
1045
- $form = $args['txt_before'] . $form . $args['txt_after'];
1046
-
1047
- // Remove line breaks if enabled for easier filtering later.
1048
- $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
1049
-
1050
- /**
1051
- * Filter the generated HTML of the entire form.
1052
- *
1053
- * @since 2.7.4
1054
- *
1055
- * @param string $form The HTML of the final generated form.
1056
- * @param string $tag Toggle new registration or profile update. new|edit.
1057
- * @param array $rows {
1058
- * An array containing the form rows.
1059
- *
1060
- * @type string order Field display order.
1061
- * @type string meta Field meta tag (not used for display).
1062
- * @type string type Input field type (not used for display).
1063
- * @type string value Input field value (not used for display).
1064
- * @type string values The possible values for the field (dropdown, multiple select/checkbox, radio group).
1065
- * @type string label_text Raw text for the label (not used for display).
1066
- * @type string row_before Opening wrapper tag around the row.
1067
- * @type string label Label tag.
1068
- * @type string field_before Opening wrapper tag before the input tag.
1069
- * @type string field The field input tag.
1070
- * @type string field_after Closing wrapper tag around the input tag.
1071
- * @type string row_after Closing wrapper tag around the row.
1072
- * }
1073
- * @param string $hidden The HTML string of hidden fields
1074
- */
1075
- $form = apply_filters( 'wpmem_register_form', $form, $tag, $rows, $hidden );
1076
-
1077
- /**
1078
- * Filter before the form.
1079
- *
1080
- * This rarely used filter allows you to stick any string onto the front of
1081
- * the generated form.
1082
- *
1083
- * @since 2.7.4
1084
- *
1085
- * @param string $str The HTML to add before the form. Default null.
1086
- * @param string $tag Toggle new registration or profile update. new|edit.
1087
- */
1088
- $form = apply_filters( 'wpmem_register_form_before', '', $tag ) . $form;
1089
-
1090
- // Return the generated form.
1091
- return $form;
1092
  } // End wpmem_inc_registration.
1093
  endif;
1094
 
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Form Building Functions
14
  * @author Chad Butler
15
+ * @copyright 2006-2017
16
  *
17
  * Functions Included:
18
  * - wpmem_inc_login
57
  // This shown above blocked content.
58
  $msg = $wpmem->get_text( 'restricted_msg' );
59
  $msg = ( $dialogs['restricted_msg'] == $msg ) ? $msg : __( stripslashes( $dialogs['restricted_msg'] ), 'wp-members' );
60
+ $str = '<div id="wpmem_restricted_msg"><p>' . $msg . '</p></div>';
61
 
62
  /**
63
  * Filter the post restricted message.
265
  * Builds the form used for login, change password, and reset password.
266
  *
267
  * @since 2.5.1
268
+ * @since 3.1.7 Now a wrapper for $wpmem->forms->login_form()
269
  *
270
  * @param string $page
271
  * @param array $arr {
291
  * @return string $form The HTML for the form as a string.
292
  */
293
  function wpmem_login_form( $page, $arr ) {
 
294
  global $wpmem;
295
+ return $wpmem->forms->login_form( $page, $arr );
296
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  endif;
298
 
299
 
304
  * Outputs the form for new user registration and existing user edits.
305
  *
306
  * @since 2.5.1
307
+ * @since 3.1.7 Now a wrapper for $wpmem->forms->register_form()
308
  *
309
  * @global object $wpmem The WP_Members object.
 
 
310
  * @param string $tag (optional) Toggles between new registration ('new') and user profile edit ('edit').
311
  * @param string $heading (optional) The heading text for the form, null (default) for new registration.
312
  * @return string $form The HTML for the entire form as a string.
313
  */
314
  function wpmem_inc_registration( $tag = 'new', $heading = '', $redirect_to = null ) {
315
+ global $wpmem;
316
+ return $wpmem->forms->register_form( $tag, $heading, $redirect_to );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  } // End wpmem_inc_registration.
318
  endif;
319
 
inc/register.php CHANGED
@@ -6,13 +6,13 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Registration Functions
14
  * @author Chad Butler
15
- * @copyright 2006-2016
16
  *
17
  * Functions Included:
18
  * - wpmem_registration
@@ -53,46 +53,47 @@ function wpmem_registration( $tag ) {
53
 
54
  // Is this a registration or a user profile update?
55
  if ( $tag == 'register' ) {
56
- $fields['username'] = ( isset( $_POST['user_login'] ) ) ? sanitize_user( $_POST['user_login'] ) : '';
57
  }
58
 
59
- // Add the user email to the $fields array for _data hooks.
60
- $fields['user_email'] = ( isset( $_POST['user_email'] ) ) ? sanitize_email( $_POST['user_email'] ) : '';
61
 
62
  /** This filter defined in inc/class-wp-members-forms.php */
63
- $wpmem_fields = apply_filters( 'wpmem_register_fields_arr', wpmem_fields(), $tag );
 
64
 
65
- // Build the $fields array from $_POST data.
66
- foreach ( $wpmem_fields as $meta_key => $field ) {
67
  if ( $field['register'] ) {
68
  if ( 'password' != $meta_key || 'confirm_password' != $meta_key ) {
69
  if ( isset( $_POST[ $meta_key ] ) ) {
70
  switch ( $field['type'] ) {
71
  case 'checkbox':
72
- $fields[ $meta_key ] = sanitize_text_field( $_POST[ $meta_key ] );
73
  break;
74
  case 'multiselect':
75
  case 'multicheckbox':
76
  $delimiter = ( isset( $field['delimiter'] ) ) ? $field['delimiter'] : '|';
77
- $fields[ $meta_key ] = ( isset( $_POST[ $meta_key ] ) ) ? implode( $delimiter, $_POST[ $meta_key ] ) : '';
78
  break;
79
  case 'textarea':
80
- $fields[ $meta_key ] = $_POST[ $meta_key ];
81
  break;
82
  default:
83
- $fields[ $meta_key ] = sanitize_text_field( $_POST[ $meta_key ] );
84
  break;
85
  }
86
  } else {
87
- $fields[ $meta_key ] = '';
88
  }
89
  } else {
90
  // We do have password as part of the registration form.
91
  if ( isset( $_POST['password'] ) ) {
92
- $fields['password'] = $_POST['password'];
93
  }
94
  if ( isset( $_POST['confirm_password'] ) ) {
95
- $fields['confirm_password'] = $_POST['confirm_password'];
96
  }
97
  }
98
  }
@@ -102,13 +103,15 @@ function wpmem_registration( $tag ) {
102
  * Filter the submitted form fields prior to validation.
103
  *
104
  * @since 2.8.2
 
105
  *
106
- * @param array $fields An array of the posted form field data.
 
107
  */
108
- $fields = apply_filters( 'wpmem_pre_validate_form', $fields );
109
 
110
  // Check for required fields, reverse the array for logical error message order.
111
- $wpmem_fields_rev = array_reverse( $wpmem_fields );
112
 
113
  foreach ( $wpmem_fields_rev as $meta_key => $field ) {
114
  $pass_arr = array( 'password', 'confirm_password', 'password_confirm' );
@@ -125,7 +128,7 @@ function wpmem_registration( $tag ) {
125
  }
126
  } else {
127
  // If the required field is any other field type.
128
- if ( ! $fields[ $meta_key ] ) {
129
  $wpmem_themsg = sprintf( $wpmem->get_text( 'reg_empty_field' ), __( $field['label'], 'wp-members' ) );
130
  }
131
  }
@@ -138,7 +141,7 @@ function wpmem_registration( $tag ) {
138
 
139
  if ( is_multisite() ) {
140
  // Multisite has different requirements.
141
- $result = wpmu_validate_user_signup( $fields['username'], $fields['user_email'] );
142
  $errors = $result['errors'];
143
  if ( $errors->errors ) {
144
  $wpmem_themsg = $errors->get_error_message(); return $wpmem_themsg; exit;
@@ -146,11 +149,11 @@ function wpmem_registration( $tag ) {
146
 
147
  } else {
148
  // Validate username and email fields.
149
- $wpmem_themsg = ( email_exists( $fields['user_email'] ) ) ? "email" : $wpmem_themsg;
150
- $wpmem_themsg = ( username_exists( $fields['username'] ) ) ? "user" : $wpmem_themsg;
151
- $wpmem_themsg = ( ! is_email( $fields['user_email']) ) ? $wpmem->get_text( 'reg_valid_email' ) : $wpmem_themsg;
152
- $wpmem_themsg = ( ! validate_username( $fields['username'] ) ) ? $wpmem->get_text( 'reg_non_alphanumeric' ) : $wpmem_themsg;
153
- $wpmem_themsg = ( ! $fields['username'] ) ? $wpmem->get_text( 'reg_empty_username' ) : $wpmem_themsg;
154
 
155
  // If there is an error from username, email, or required field validation, stop registration and return the error.
156
  if ( $wpmem_themsg ) {
@@ -160,10 +163,10 @@ function wpmem_registration( $tag ) {
160
  }
161
 
162
  // If form contains password and email confirmation, validate that they match.
163
- if ( array_key_exists( 'confirm_password', $fields ) && $fields['confirm_password'] != $fields ['password'] ) {
164
  $wpmem_themsg = $wpmem->get_text( 'reg_password_match' );
165
  }
166
- if ( array_key_exists( 'confirm_email', $fields ) && $fields['confirm_email'] != $fields ['user_email'] ) {
167
  $wpmem_themsg = $wpmem->get_text( 'reg_email_match' );
168
  }
169
 
@@ -176,32 +179,31 @@ function wpmem_registration( $tag ) {
176
  }
177
 
178
  // Check for user defined password.
179
- $fields['password'] = ( ! isset( $_POST['password'] ) ) ? wp_generate_password() : $_POST['password'];
180
 
181
  // Add for _data hooks
182
- $fields['user_registered'] = current_time( 'mysql', 1 );
183
- $fields['user_role'] = get_option( 'default_role' );
184
- $fields['wpmem_reg_ip'] = $_SERVER['REMOTE_ADDR'];
185
- $fields['wpmem_reg_url'] = ( isset( $_REQUEST['wpmem_reg_page'] ) ) ? $_REQUEST['wpmem_reg_page'] : $_REQUEST['redirect_to'];
186
 
187
  /*
188
  * These native fields are not installed by default, but if they
189
  * are added, use the $_POST value - otherwise, default to username.
190
  * Value can be filtered with wpmem_register_data.
191
  */
192
- $fields['user_nicename'] = ( isset( $_POST['user_nicename'] ) ) ? sanitize_title( $_POST['user_nicename'] ) : $fields['username'];
193
- $fields['display_name'] = ( isset( $_POST['display_name'] ) ) ? sanitize_user ( $_POST['display_name'] ) : $fields['username'];
194
- $fields['nickname'] = ( isset( $_POST['nickname'] ) ) ? sanitize_user ( $_POST['nickname'] ) : $fields['username'];
195
-
196
  /**
197
  * Filter registration data after validation before data insertion.
198
  *
199
  * @since 2.8.2
200
  *
201
- * @param array $fields An array of the registration field data.
202
  * @param string $tag A switch to indicate the action (new|edit).
203
  */
204
- $fields = apply_filters( 'wpmem_register_data', $fields, 'new' );
205
 
206
  /**
207
  * Fires before any insertion/emails.
@@ -213,9 +215,9 @@ function wpmem_registration( $tag ) {
213
  *
214
  * @since 2.7.2
215
  *
216
- * @param array $fields The user's submitted registration data.
217
  */
218
- do_action( 'wpmem_pre_register_data', $fields );
219
 
220
  // If the _pre_register_data hook sends back an error message.
221
  if ( $wpmem_themsg ) {
@@ -224,105 +226,34 @@ function wpmem_registration( $tag ) {
224
 
225
  // Main new user fields are ready.
226
  $new_user_fields = array (
227
- 'user_pass' => $fields['password'],
228
- 'user_login' => $fields['username'],
229
- 'user_nicename' => $fields['user_nicename'],
230
- 'user_email' => $fields['user_email'],
231
- 'display_name' => $fields['display_name'],
232
- 'nickname' => $fields['nickname'],
233
- 'user_registered' => $fields['user_registered'],
234
- 'role' => $fields['user_role']
235
  );
236
 
237
  // Get any excluded meta fields.
238
- $excluded_meta = wpmem_get_excluded_meta( 'register' );
239
 
240
  // Fields for wp_insert_user: user_url, first_name, last_name, description, jabber, aim, yim.
241
  $new_user_fields_meta = array( 'user_url', 'first_name', 'last_name', 'description', 'jabber', 'aim', 'yim' );
242
- foreach ( $wpmem_fields as $meta_key => $field ) {
243
  if ( in_array( $meta_key, $new_user_fields_meta ) ) {
244
- if ( $field['register'] && ! in_array( $meta_key, $excluded_meta ) ) {
245
- $new_user_fields[ $meta_key ] = $fields[ $meta_key ];
246
  }
247
  }
248
  }
249
 
250
  // Inserts to wp_users table.
251
- $fields['ID'] = wp_insert_user( $new_user_fields );
252
-
253
- // Set remaining fields to wp_usermeta table.
254
- foreach ( $wpmem_fields as $meta_key => $field ) {
255
- // If the field is not excluded, update accordingly.
256
- if ( ! in_array( $meta_key, $excluded_meta ) && ! in_array( $meta_key, $new_user_fields_meta ) ) {
257
- if ( $field['register'] && 'user_email' != $meta_key ) {
258
- update_user_meta( $fields['ID'], $meta_key, $fields[ $meta_key ] );
259
- }
260
- }
261
- }
262
-
263
- // Capture IP address of user at registration.
264
- update_user_meta( $fields['ID'], 'wpmem_reg_ip', $fields['wpmem_reg_ip'] );
265
-
266
- // Store the registration url.
267
- update_user_meta( $fields['ID'], 'wpmem_reg_url', $fields['wpmem_reg_url'] );
268
-
269
- // Set user expiration, if used.
270
- if ( $wpmem->use_exp == 1 && $wpmem->mod_reg != 1 ) {
271
- if ( function_exists( 'wpmem_set_exp' ) ) {
272
- wpmem_set_exp( $fields['ID'] );
273
- }
274
- }
275
-
276
- // Handle file uploads, if any.
277
- if ( ! empty( $_FILES ) ) {
278
-
279
- foreach ( $wpmem_fields as $meta_key => $field ) {
280
-
281
- if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && is_array( $_FILES[ $meta_key ] ) ) {
282
-
283
- // Upload the file and save it as an attachment.
284
- $file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $fields['ID'] );
285
-
286
- // Save the attachment ID as user meta.
287
- update_user_meta( $fields['ID'], $meta_key, $file_post_id );
288
- }
289
- }
290
- }
291
-
292
- /**
293
- * Fires after user insertion but before email.
294
- *
295
- * @since 2.7.2
296
- *
297
- * @param array $fields The user's submitted registration data.
298
- */
299
- do_action( 'wpmem_post_register_data', $fields );
300
-
301
- /*
302
- * If this was successful, and you have email properly
303
- * configured, send a notification email to the user.
304
- */
305
- wpmem_inc_regemail( $fields['ID'], $fields['password'], $wpmem->mod_reg, $wpmem_fields, $fields );
306
-
307
- // Notify admin of new reg, if needed.
308
- if ( $wpmem->notify == 1 ) {
309
- wpmem_notify_admin( $fields['ID'], $wpmem_fields, $fields );
310
- }
311
-
312
- if ( isset( $_POST['redirect_to'] ) ) {
313
- $nonce_url = wp_nonce_url( $_POST['redirect_to'], 'register_redirect', 'nonce' );
314
- $url = add_query_arg( 'reg', 'success', $nonce_url );
315
- wp_redirect( $url );
316
- exit();
317
- }
318
-
319
- /**
320
- * Fires after registration is complete.
321
- *
322
- * @since 2.7.1
323
- * @since 3.1.0 Added $fields
324
- */
325
- do_action( 'wpmem_register_redirect', $fields );
326
 
327
  // successful registration message
328
  return "success"; exit();
@@ -340,12 +271,12 @@ function wpmem_registration( $tag ) {
340
  * see if it's different, then check if it is a valid address and it exists.
341
  */
342
  global $current_user; wp_get_current_user();
343
- if ( $fields['user_email'] != $current_user->user_email ) {
344
- if ( email_exists( $fields['user_email'] ) ) {
345
  return "email";
346
  exit();
347
  }
348
- if ( !is_email( $fields['user_email']) ) {
349
  $wpmem_themsg = $wpmem->get_text( 'reg_valid_email' );
350
  return "updaterr";
351
  exit();
@@ -353,17 +284,17 @@ function wpmem_registration( $tag ) {
353
  }
354
 
355
  // If form includes email confirmation, validate that they match.
356
- if ( array_key_exists( 'confirm_email', $fields ) && $fields['confirm_email'] != $fields ['user_email'] ) {
357
  $wpmem_themsg = $wpmem->get_text( 'reg_email_match' );
358
  return "updaterr";
359
  exit();
360
  }
361
 
362
  // Add the user_ID to the fields array.
363
- $fields['ID'] = $user_ID;
364
 
365
  /** This filter is documented in register.php */
366
- $fields = apply_filters( 'wpmem_register_data', $fields, 'edit' );
367
 
368
  /**
369
  * Fires before data insertion.
@@ -375,9 +306,9 @@ function wpmem_registration( $tag ) {
375
  *
376
  * @since 2.7.2
377
  *
378
- * @param array $fields The user's submitted update data.
379
  */
380
- do_action( 'wpmem_pre_update_data', $fields );
381
 
382
  // If the _pre_update_data hook sends back an error message.
383
  if ( $wpmem_themsg ){
@@ -401,7 +332,7 @@ function wpmem_registration( $tag ) {
401
  );
402
  $native_update = array( 'ID' => $user_ID );
403
 
404
- foreach ( $wpmem_fields as $meta_key => $field ) {
405
  // If the field is not excluded, update accordingly.
406
  if ( ! in_array( $meta_key, wpmem_get_excluded_meta( 'update' ) ) ) {
407
  if ( 'file' != $field['type'] && 'image' != $field['type'] ) {
@@ -409,8 +340,8 @@ function wpmem_registration( $tag ) {
409
 
410
  // If the field can be updated by wp_update_user.
411
  case( in_array( $meta_key, $native_fields ) ):
412
- $fields[ $meta_key ] = ( isset( $fields[ $meta_key ] ) ) ? $fields[ $meta_key ] : '';
413
- $native_update[ $meta_key ] = $fields[ $meta_key ];
414
  break;
415
 
416
  // If the field is password.
@@ -421,7 +352,7 @@ function wpmem_registration( $tag ) {
421
  // Everything else goes into wp_usermeta.
422
  default:
423
  if ( $field['register'] ) {
424
- update_user_meta( $user_ID, $meta_key, $fields[ $meta_key ] );
425
  }
426
  break;
427
  }
@@ -432,15 +363,15 @@ function wpmem_registration( $tag ) {
432
  // Handle file uploads, if any.
433
  if ( ! empty( $_FILES ) ) {
434
 
435
- foreach ( $wpmem_fields as $meta_key => $field ) {
436
 
437
  if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && is_array( $_FILES[ $meta_key ] ) ) {
438
  if ( ! empty( $_FILES[ $meta_key ]['name'] ) ) {
439
  // Upload the file and save it as an attachment.
440
- $file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $fields['ID'] );
441
 
442
  // Save the attachment ID as user meta.
443
- update_user_meta( $fields['ID'], $meta_key, $file_post_id );
444
  }
445
  }
446
  }
@@ -454,9 +385,9 @@ function wpmem_registration( $tag ) {
454
  *
455
  * @since 2.7.2
456
  *
457
- * @param array $fields The user's submitted registration data.
458
  */
459
- do_action( 'wpmem_post_update_data', $fields );
460
 
461
  return "editsuccess"; exit();
462
  break;
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Registration Functions
14
  * @author Chad Butler
15
+ * @copyright 2006-2017
16
  *
17
  * Functions Included:
18
  * - wpmem_registration
53
 
54
  // Is this a registration or a user profile update?
55
  if ( $tag == 'register' ) {
56
+ $wpmem->user->post_data['username'] = sanitize_user( wpmem_get( 'user_login' ) );
57
  }
58
 
59
+ // Add the user email to the $wpmem->user->post_data array for _data hooks.
60
+ $wpmem->user->post_data['user_email'] = sanitize_email( wpmem_get( 'user_email' ) );
61
 
62
  /** This filter defined in inc/class-wp-members-forms.php */
63
+ /** @deprecated 3.1.7 Use wpmem_fields instead. */
64
+ $wpmem->fields = apply_filters( 'wpmem_register_fields_arr', wpmem_fields( $tag ), $tag );
65
 
66
+ // Build the $wpmem->user->post_data array from $_POST data.
67
+ foreach ( $wpmem->fields as $meta_key => $field ) {
68
  if ( $field['register'] ) {
69
  if ( 'password' != $meta_key || 'confirm_password' != $meta_key ) {
70
  if ( isset( $_POST[ $meta_key ] ) ) {
71
  switch ( $field['type'] ) {
72
  case 'checkbox':
73
+ $wpmem->user->post_data[ $meta_key ] = sanitize_text_field( $_POST[ $meta_key ] );
74
  break;
75
  case 'multiselect':
76
  case 'multicheckbox':
77
  $delimiter = ( isset( $field['delimiter'] ) ) ? $field['delimiter'] : '|';
78
+ $wpmem->user->post_data[ $meta_key ] = ( isset( $_POST[ $meta_key ] ) ) ? implode( $delimiter, $_POST[ $meta_key ] ) : '';
79
  break;
80
  case 'textarea':
81
+ $wpmem->user->post_data[ $meta_key ] = $_POST[ $meta_key ];
82
  break;
83
  default:
84
+ $wpmem->user->post_data[ $meta_key ] = sanitize_text_field( $_POST[ $meta_key ] );
85
  break;
86
  }
87
  } else {
88
+ $wpmem->user->post_data[ $meta_key ] = '';
89
  }
90
  } else {
91
  // We do have password as part of the registration form.
92
  if ( isset( $_POST['password'] ) ) {
93
+ $wpmem->user->post_data['password'] = $_POST['password'];
94
  }
95
  if ( isset( $_POST['confirm_password'] ) ) {
96
+ $wpmem->user->post_data['confirm_password'] = $_POST['confirm_password'];
97
  }
98
  }
99
  }
103
  * Filter the submitted form fields prior to validation.
104
  *
105
  * @since 2.8.2
106
+ * @since 3.1.7 Added $tag
107
  *
108
+ * @param array $wpmem->user->post_data An array of the posted form field data.
109
+ * @param string $tag
110
  */
111
+ $wpmem->user->post_data = apply_filters( 'wpmem_pre_validate_form', $wpmem->user->post_data, $tag );
112
 
113
  // Check for required fields, reverse the array for logical error message order.
114
+ $wpmem_fields_rev = array_reverse( $wpmem->fields );
115
 
116
  foreach ( $wpmem_fields_rev as $meta_key => $field ) {
117
  $pass_arr = array( 'password', 'confirm_password', 'password_confirm' );
128
  }
129
  } else {
130
  // If the required field is any other field type.
131
+ if ( ! $wpmem->user->post_data[ $meta_key ] ) {
132
  $wpmem_themsg = sprintf( $wpmem->get_text( 'reg_empty_field' ), __( $field['label'], 'wp-members' ) );
133
  }
134
  }
141
 
142
  if ( is_multisite() ) {
143
  // Multisite has different requirements.
144
+ $result = wpmu_validate_user_signup( $wpmem->user->post_data['username'], $wpmem->user->post_data['user_email'] );
145
  $errors = $result['errors'];
146
  if ( $errors->errors ) {
147
  $wpmem_themsg = $errors->get_error_message(); return $wpmem_themsg; exit;
149
 
150
  } else {
151
  // Validate username and email fields.
152
+ $wpmem_themsg = ( email_exists( $wpmem->user->post_data['user_email'] ) ) ? "email" : $wpmem_themsg;
153
+ $wpmem_themsg = ( username_exists( $wpmem->user->post_data['username'] ) ) ? "user" : $wpmem_themsg;
154
+ $wpmem_themsg = ( ! is_email( $wpmem->user->post_data['user_email']) ) ? $wpmem->get_text( 'reg_valid_email' ) : $wpmem_themsg;
155
+ $wpmem_themsg = ( ! validate_username( $wpmem->user->post_data['username'] ) ) ? $wpmem->get_text( 'reg_non_alphanumeric' ) : $wpmem_themsg;
156
+ $wpmem_themsg = ( ! $wpmem->user->post_data['username'] ) ? $wpmem->get_text( 'reg_empty_username' ) : $wpmem_themsg;
157
 
158
  // If there is an error from username, email, or required field validation, stop registration and return the error.
159
  if ( $wpmem_themsg ) {
163
  }
164
 
165
  // If form contains password and email confirmation, validate that they match.
166
+ if ( array_key_exists( 'confirm_password', $wpmem->user->post_data ) && $wpmem->user->post_data['confirm_password'] != $wpmem->user->post_data ['password'] ) {
167
  $wpmem_themsg = $wpmem->get_text( 'reg_password_match' );
168
  }
169
+ if ( array_key_exists( 'confirm_email', $wpmem->user->post_data ) && $wpmem->user->post_data['confirm_email'] != $wpmem->user->post_data ['user_email'] ) {
170
  $wpmem_themsg = $wpmem->get_text( 'reg_email_match' );
171
  }
172
 
179
  }
180
 
181
  // Check for user defined password.
182
+ $wpmem->user->post_data['password'] = wpmem_get( 'password', wp_generate_password() );
183
 
184
  // Add for _data hooks
185
+ $wpmem->user->post_data['user_registered'] = current_time( 'mysql', 1 );
186
+ $wpmem->user->post_data['user_role'] = get_option( 'default_role' );
187
+ $wpmem->user->post_data['wpmem_reg_ip'] = $_SERVER['REMOTE_ADDR'];
188
+ $wpmem->user->post_data['wpmem_reg_url'] = wpmem_get( 'wpmem_reg_page', wpmem_get( 'redirect_to', false, 'request' ), 'request' );
189
 
190
  /*
191
  * These native fields are not installed by default, but if they
192
  * are added, use the $_POST value - otherwise, default to username.
193
  * Value can be filtered with wpmem_register_data.
194
  */
195
+ $wpmem->user->post_data['user_nicename'] = wpmem_get( 'user_nicename', $wpmem->user->post_data['username'] );
196
+ $wpmem->user->post_data['display_name'] = wpmem_get( 'display_name', $wpmem->user->post_data['username'] );
197
+ $wpmem->user->post_data['nickname'] = wpmem_get( 'nickname', $wpmem->user->post_data['username'] );
 
198
  /**
199
  * Filter registration data after validation before data insertion.
200
  *
201
  * @since 2.8.2
202
  *
203
+ * @param array $wpmem->user->post_data An array of the registration field data.
204
  * @param string $tag A switch to indicate the action (new|edit).
205
  */
206
+ $wpmem->user->post_data = apply_filters( 'wpmem_register_data', $wpmem->user->post_data, 'new' );
207
 
208
  /**
209
  * Fires before any insertion/emails.
215
  *
216
  * @since 2.7.2
217
  *
218
+ * @param array $wpmem->user->post_data The user's submitted registration data.
219
  */
220
+ do_action( 'wpmem_pre_register_data', $wpmem->user->post_data );
221
 
222
  // If the _pre_register_data hook sends back an error message.
223
  if ( $wpmem_themsg ) {
226
 
227
  // Main new user fields are ready.
228
  $new_user_fields = array (
229
+ 'user_pass' => $wpmem->user->post_data['password'],
230
+ 'user_login' => $wpmem->user->post_data['username'],
231
+ 'user_nicename' => $wpmem->user->post_data['user_nicename'],
232
+ 'user_email' => $wpmem->user->post_data['user_email'],
233
+ 'display_name' => $wpmem->user->post_data['display_name'],
234
+ 'nickname' => $wpmem->user->post_data['nickname'],
235
+ 'user_registered' => $wpmem->user->post_data['user_registered'],
236
+ 'role' => $wpmem->user->post_data['user_role']
237
  );
238
 
239
  // Get any excluded meta fields.
240
+ $wpmem->excluded_meta = wpmem_get_excluded_meta( 'register' );
241
 
242
  // Fields for wp_insert_user: user_url, first_name, last_name, description, jabber, aim, yim.
243
  $new_user_fields_meta = array( 'user_url', 'first_name', 'last_name', 'description', 'jabber', 'aim', 'yim' );
244
+ foreach ( $wpmem->fields as $meta_key => $field ) {
245
  if ( in_array( $meta_key, $new_user_fields_meta ) ) {
246
+ if ( $field['register'] && ! in_array( $meta_key, $wpmem->excluded_meta ) ) {
247
+ $new_user_fields[ $meta_key ] = $wpmem->user->post_data[ $meta_key ];
248
  }
249
  }
250
  }
251
 
252
  // Inserts to wp_users table.
253
+ $user_id = wp_insert_user( $new_user_fields );
254
+
255
+ // @todo Temporarily run custom field handling until testing on new user_register hook is complete.
256
+ $wpmem->user->register( $user_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
  // successful registration message
259
  return "success"; exit();
271
  * see if it's different, then check if it is a valid address and it exists.
272
  */
273
  global $current_user; wp_get_current_user();
274
+ if ( $wpmem->user->post_data['user_email'] != $current_user->user_email ) {
275
+ if ( email_exists( $wpmem->user->post_data['user_email'] ) ) {
276
  return "email";
277
  exit();
278
  }
279
+ if ( !is_email( $wpmem->user->post_data['user_email']) ) {
280
  $wpmem_themsg = $wpmem->get_text( 'reg_valid_email' );
281
  return "updaterr";
282
  exit();
284
  }
285
 
286
  // If form includes email confirmation, validate that they match.
287
+ if ( array_key_exists( 'confirm_email', $wpmem->user->post_data ) && $wpmem->user->post_data['confirm_email'] != $wpmem->user->post_data ['user_email'] ) {
288
  $wpmem_themsg = $wpmem->get_text( 'reg_email_match' );
289
  return "updaterr";
290
  exit();
291
  }
292
 
293
  // Add the user_ID to the fields array.
294
+ $wpmem->user->post_data['ID'] = $user_ID;
295
 
296
  /** This filter is documented in register.php */
297
+ $wpmem->user->post_data = apply_filters( 'wpmem_register_data', $wpmem->user->post_data, 'edit' );
298
 
299
  /**
300
  * Fires before data insertion.
306
  *
307
  * @since 2.7.2
308
  *
309
+ * @param array $wpmem->user->post_data The user's submitted update data.
310
  */
311
+ do_action( 'wpmem_pre_update_data', $wpmem->user->post_data );
312
 
313
  // If the _pre_update_data hook sends back an error message.
314
  if ( $wpmem_themsg ){
332
  );
333
  $native_update = array( 'ID' => $user_ID );
334
 
335
+ foreach ( $wpmem->fields as $meta_key => $field ) {
336
  // If the field is not excluded, update accordingly.
337
  if ( ! in_array( $meta_key, wpmem_get_excluded_meta( 'update' ) ) ) {
338
  if ( 'file' != $field['type'] && 'image' != $field['type'] ) {
340
 
341
  // If the field can be updated by wp_update_user.
342
  case( in_array( $meta_key, $native_fields ) ):
343
+ $wpmem->user->post_data[ $meta_key ] = ( isset( $wpmem->user->post_data[ $meta_key ] ) ) ? $wpmem->user->post_data[ $meta_key ] : '';
344
+ $native_update[ $meta_key ] = $wpmem->user->post_data[ $meta_key ];
345
  break;
346
 
347
  // If the field is password.
352
  // Everything else goes into wp_usermeta.
353
  default:
354
  if ( $field['register'] ) {
355
+ update_user_meta( $user_ID, $meta_key, $wpmem->user->post_data[ $meta_key ] );
356
  }
357
  break;
358
  }
363
  // Handle file uploads, if any.
364
  if ( ! empty( $_FILES ) ) {
365
 
366
+ foreach ( $wpmem->fields as $meta_key => $field ) {
367
 
368
  if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && is_array( $_FILES[ $meta_key ] ) ) {
369
  if ( ! empty( $_FILES[ $meta_key ]['name'] ) ) {
370
  // Upload the file and save it as an attachment.
371
+ $file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $wpmem->user->post_data['ID'] );
372
 
373
  // Save the attachment ID as user meta.
374
+ update_user_meta( $wpmem->user->post_data['ID'], $meta_key, $file_post_id );
375
  }
376
  }
377
  }
385
  *
386
  * @since 2.7.2
387
  *
388
+ * @param array $wpmem->user->post_data The user's submitted registration data.
389
  */
390
+ do_action( 'wpmem_post_update_data', $wpmem->user->post_data );
391
 
392
  return "editsuccess"; exit();
393
  break;
inc/shortcodes.php CHANGED
@@ -6,19 +6,18 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Shortcodes
14
  * @author Chad Butler
15
- * @copyright 2006-2016
16
  *
17
  * Functions Included:
18
  * - wpmem_sc_forms
19
  * - wpmem_sc_logged_in
20
  * - wpmem_sc_logged_out
21
- * - wpmem_shortcode
22
  * - wpmem_do_sc_pages
23
  * - wpmem_sc_user_count
24
  * - wpmem_sc_user_profile
@@ -127,16 +126,17 @@ function wpmem_sc_forms( $atts, $content = null, $tag = 'wpmem_form' ) {
127
  * [wpmem_txt] shortcode is even included. @todo - Is this a temporary solution or is there something
128
  * cleaner that can be worked out?
129
  */
130
- if ( array_key_exists( 'texturize', $atts ) && $atts['texturize'] == 'false' ) {
131
- $content = str_replace( array( '[wpmem_txt]', '[/wpmem_txt]' ), array( '', '' ), $content );
132
- }
133
- if ( strstr( $content, '[wpmem_txt]' ) ) {
134
- // Fixes the wptexturize.
135
- remove_filter( 'the_content', 'wpautop' );
136
- remove_filter( 'the_content', 'wptexturize' );
137
- add_filter( 'the_content', 'wpmem_texturize', 999 );
138
- }
139
- // End texturize functions */
 
140
  }
141
  return do_shortcode( $content );
142
  }
@@ -249,94 +249,6 @@ function wpmem_sc_logged_out( $atts, $content = null, $tag ) {
249
  return ( ! is_user_logged_in() ) ? do_shortcode( $content ) : '';
250
  }
251
 
252
- if ( ! function_exists( 'wpmem_shortcode' ) ):
253
- /**
254
- * Executes various shortcodes.
255
- *
256
- * This function executes shortcodes for pages (settings, register, login, user-list,
257
- * and tos pages), as well as login status and field attributes when the wp-members tag
258
- * is used. Also executes shortcodes for login status with the wpmem_logged_in tags
259
- * and fields when the wpmem_field tags are used.
260
- *
261
- * @since 2.4.0
262
- * @deprecated 3.1.2
263
- *
264
- * @global object $wpmem The WP_Members object.
265
- *
266
- * @param array $attr {
267
- * The shortcode attributes.
268
- *
269
- * @type string $page
270
- * @type string $url
271
- * @type string $status
272
- * @type string $msg
273
- * @type string $field
274
- * @type int $id
275
- * }
276
- * @param string $content
277
- * @param string $tag
278
- * @return string Returns the result of wpmem_do_sc_pages|wpmem_list_users|wpmem_sc_expmessage|$content.
279
- */
280
- function wpmem_shortcode( $attr, $content = null, $tag = 'wp-members' ) {
281
-
282
- $error = "wpmem_shortcode() is deprecated as of WP-Members 3.1.2. The [wp-members] shortcode tag should be replaced. ";
283
- $error.= 'See replacement shortcodes: http://rkt.bz/logsc ';
284
- $error.= "post ID: " . get_the_ID() . " ";
285
- $error.= "page url: " . wpmem_current_url();
286
- wpmem_write_log( $error );
287
-
288
- global $wpmem;
289
-
290
- // Set all default attributes to false.
291
- $defaults = array(
292
- 'page' => false,
293
- 'redirect_to' => null,
294
- 'url' => false,
295
- 'status' => false,
296
- 'msg' => false,
297
- 'field' => false,
298
- 'id' => false,
299
- 'underscores' => 'off',
300
- );
301
-
302
- // Merge defaults with $attr.
303
- $atts = shortcode_atts( $defaults, $attr, $tag );
304
-
305
- // Handles the 'page' attribute.
306
- if ( $atts['page'] ) {
307
- if ( $atts['page'] == 'user-list' ) {
308
- if ( function_exists( 'wpmem_list_users' ) ) {
309
- $content = do_shortcode( wpmem_list_users( $attr, $content ) );
310
- }
311
- } elseif ( $atts['page'] == 'tos' ) {
312
- return $atts['url'];
313
- } else {
314
- $content = do_shortcode( wpmem_do_sc_pages( $atts, $content, $tag ) );
315
- }
316
-
317
- // Resolve any texturize issues.
318
- if ( strstr( $content, '[wpmem_txt]' ) ) {
319
- // Fixes the wptexturize.
320
- remove_filter( 'the_content', 'wpautop' );
321
- remove_filter( 'the_content', 'wptexturize' );
322
- add_filter( 'the_content', 'wpmem_texturize', 999 );
323
- }
324
- return $content;
325
- }
326
-
327
- // Handles the 'status' attribute.
328
- if ( ( $atts['status'] ) || $tag == 'wpmem_logged_in' ) {
329
- return wpmem_sc_logged_in( $atts, $content, $tag );
330
- }
331
-
332
- // Handles the 'field' attribute.
333
- if ( $atts['field'] || $tag == 'wpmem_field' ) {
334
- return wpmem_sc_fields( $atts, $content, $tag );
335
- }
336
-
337
- }
338
- endif;
339
-
340
  if ( ! function_exists( 'wpmem_do_sc_pages' ) ):
341
  /**
342
  * Builds the shortcode pages (login, register, user-profile, user-edit, password).
@@ -728,4 +640,57 @@ function wpmem_sc_tos( $atts, $content, $tag ) {
728
  return do_shortcode( $atts['url'] );
729
  }
730
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
731
  // End of file.
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Shortcodes
14
  * @author Chad Butler
15
+ * @copyright 2006-2017
16
  *
17
  * Functions Included:
18
  * - wpmem_sc_forms
19
  * - wpmem_sc_logged_in
20
  * - wpmem_sc_logged_out
 
21
  * - wpmem_do_sc_pages
22
  * - wpmem_sc_user_count
23
  * - wpmem_sc_user_profile
126
  * [wpmem_txt] shortcode is even included. @todo - Is this a temporary solution or is there something
127
  * cleaner that can be worked out?
128
  */
129
+ if ( 1 == $wpmem->texturize ) {
130
+ if ( array_key_exists( 'texturize', $atts ) && $atts['texturize'] == 'false' ) {
131
+ $content = str_replace( array( '[wpmem_txt]', '[/wpmem_txt]' ), array( '', '' ), $content );
132
+ }
133
+ if ( strstr( $content, '[wpmem_txt]' ) ) {
134
+ // Fixes the wptexturize.
135
+ remove_filter( 'the_content', 'wpautop' );
136
+ remove_filter( 'the_content', 'wptexturize' );
137
+ add_filter( 'the_content', 'wpmem_texturize', 999 );
138
+ }
139
+ } // End texturize functions
140
  }
141
  return do_shortcode( $content );
142
  }
249
  return ( ! is_user_logged_in() ) ? do_shortcode( $content ) : '';
250
  }
251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  if ( ! function_exists( 'wpmem_do_sc_pages' ) ):
253
  /**
254
  * Builds the shortcode pages (login, register, user-profile, user-edit, password).
640
  return do_shortcode( $atts['url'] );
641
  }
642
 
643
+ /**
644
+ * Display user avatar.
645
+ *
646
+ * @since 3.1.7
647
+ *
648
+ * @param array $atts {
649
+ * The shortcode attributes.
650
+ *
651
+ * @type string $id The user email or id.
652
+ * @type int $size Avatar size (square) in pixels.
653
+ * }
654
+ * @param string $content
655
+ * @param string $tag
656
+ * @retrun string $content
657
+ */
658
+ function wpmem_sc_avatar( $atts, $content, $tag ) {
659
+ $content = '';
660
+ $size = ( isset( $atts['size'] ) ) ? $atts['size'] : '';
661
+ if ( isset( $atts['id'] ) ) {
662
+ $content = get_avatar( $atts['id'], $size );
663
+ } elseif ( is_user_logged_in() ) {
664
+ // If the user is logged in and this isn't specifying a user ID, return the current user avatar.
665
+ global $current_user;
666
+ wp_get_current_user();
667
+ $content = get_avatar( $current_user->ID, $size );
668
+ }
669
+ return do_shortcode( $content );
670
+ }
671
+
672
+ /**
673
+ * Generates a login link with a return url.
674
+ *
675
+ * @since 3.1.7
676
+ *
677
+ * @param array $atts {
678
+ * The shortcode attributes.
679
+ * }
680
+ * @param string $content
681
+ * @param string $tag
682
+ * @retrun string $content
683
+ */
684
+ function wpmem_sc_link( $atts, $content, $tag ) {
685
+ if ( 'wpmem_reg_link' == $tag ) {
686
+ $text = ( $content ) ? $content : __( 'Register' );
687
+ $link = add_query_arg( 'redirect_to', wpmem_current_url(), wpmem_register_url() );
688
+ } else {
689
+ $text = ( $content ) ? $content : __( 'Log In' );
690
+ $link = wpmem_login_url( wpmem_current_url() );
691
+ }
692
+ $content = '<a href="' . $link . '">' . $text . '</a>';
693
+ return do_shortcode( $content );
694
+ }
695
+
696
  // End of file.
inc/sidebar.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions Included:
17
  * - wpmem_inc_status
@@ -112,6 +112,7 @@ function wpmem_do_sidebar( $redirect_to = null ) {
112
  'wrap_inputs' => true,
113
  'n' => "\n",
114
  't' => "\t",
 
115
  );
116
 
117
  /**
@@ -141,6 +142,15 @@ function wpmem_do_sidebar( $redirect_to = null ) {
141
  $row2 = $label . $args['n'] . $input . $args['n'];
142
 
143
  $form = $row1 . $row2;
 
 
 
 
 
 
 
 
 
144
 
145
  $hidden = '<input type="hidden" name="rememberme" value="forever" />' . $args['n'] .
146
  '<input type="hidden" name="redirect_to" value="' . ( ( $redirect_to ) ? $redirect_to : $post_to ) . '" />' . $args['n'] .
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions Included:
17
  * - wpmem_inc_status
112
  'wrap_inputs' => true,
113
  'n' => "\n",
114
  't' => "\t",
115
+ 'login_form_action' => true,
116
  );
117
 
118
  /**
142
  $row2 = $label . $args['n'] . $input . $args['n'];
143
 
144
  $form = $row1 . $row2;
145
+
146
+ // Handle outside elements added to the login form (currently ONLY for login).
147
+ if ( $args['login_form_action'] ) {
148
+ ob_start();
149
+ do_action( 'login_form' );
150
+ $add_to_form = ob_get_contents();
151
+ ob_end_clean();
152
+ $form.= $add_to_form;
153
+ }
154
 
155
  $hidden = '<input type="hidden" name="rememberme" value="forever" />' . $args['n'] .
156
  '<input type="hidden" name="redirect_to" value="' . ( ( $redirect_to ) ? $redirect_to : $post_to ) . '" />' . $args['n'] .
inc/users.php CHANGED
@@ -7,12 +7,12 @@
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at http://rocketgeek.com
10
- * Copyright (c) 2006-2016 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @author Chad Butler
15
- * @copyright 2006-2016
16
  */
17
 
18
 
@@ -38,7 +38,7 @@ function wpmem_user_profile() {
38
  <table class="form-table">
39
  <?php
40
  // Get fields.
41
- $wpmem_fields = wpmem_fields();
42
  // Get excluded meta.
43
  $exclude = wpmem_get_excluded_meta( 'user-profile' );
44
 
@@ -167,7 +167,7 @@ function wpmem_profile_update() {
167
 
168
  global $wpmem, $user_id;
169
  // Get the fields.
170
- $wpmem_fields = wpmem_fields();
171
  // Get any excluded meta fields.
172
  $exclude = wpmem_get_excluded_meta( 'user-profile' );
173
  foreach ( $wpmem_fields as $meta => $field ) {
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at http://rocketgeek.com
10
+ * Copyright (c) 2006-2017 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @author Chad Butler
15
+ * @copyright 2006-2017
16
  */
17
 
18
 
38
  <table class="form-table">
39
  <?php
40
  // Get fields.
41
+ $wpmem_fields = wpmem_fields( 'dashboard_profile' );
42
  // Get excluded meta.
43
  $exclude = wpmem_get_excluded_meta( 'user-profile' );
44
 
167
 
168
  global $wpmem, $user_id;
169
  // Get the fields.
170
+ $wpmem_fields = wpmem_fields( 'dashboard_profile_update' );
171
  // Get any excluded meta fields.
172
  $exclude = wpmem_get_excluded_meta( 'user-profile' );
173
  foreach ( $wpmem_fields as $meta => $field ) {
inc/utilities.php CHANGED
@@ -7,23 +7,19 @@
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at http://rocketgeek.com
10
- * Copyright (c) 2006-2016 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @subpackage WP-Members Utility Functions
15
  * @author Chad Butler
16
- * @copyright 2006-2016
17
  *
18
  * Functions included:
19
  * - wpmem_create_formfield
20
- * - wpmem_selected @deprecated 3.1.0 Use selected() or checked() instead.
21
- * - wpmem_chk_qstr @deprecated 3.1.0 Use add_query_arg() instead.
22
- * - wpmem_generatePassword @deprecated Unknown Use wp_generate_password() instead.
23
  * - wpmem_texturize
24
  * - wpmem_enqueue_style
25
  * - wpmem_do_excerpt
26
- * - wpmem_test_shortcode @deprecated 3.1.2 Use has_shortcode() instead.
27
  * - wpmem_get_excluded_meta
28
  * - wpmem_use_ssl
29
  * - wpmem_wp_reserved_terms
@@ -62,67 +58,6 @@ function wpmem_create_formfield( $name, $type, $value, $valtochk=null, $class='t
62
  endif;
63
 
64
 
65
- if ( ! function_exists( 'wpmem_selected' ) ):
66
- /**
67
- * Determines if a form field is selected (i.e. lists & checkboxes).
68
- *
69
- * @since 0.1.0
70
- * @deprecated 3.1.0 Use selected() or checked() instead.
71
- *
72
- * @param string $value
73
- * @param string $valtochk
74
- * @param string $type
75
- * @return string $issame
76
- */
77
- function wpmem_selected( $value, $valtochk, $type = null ) {
78
- wpmem_write_log( "wpmem_selected() is deprecated as of WP-Members 3.1.0. Use selected() or checked() instead" );
79
- $issame = ( $type == 'select' ) ? ' selected' : ' checked';
80
- return ( $value == $valtochk ) ? $issame : '';
81
- }
82
- endif;
83
-
84
-
85
- if ( ! function_exists( 'wpmem_chk_qstr' ) ):
86
- /**
87
- * Checks querystrings.
88
- *
89
- * @since 2.0.0
90
- * @deprecated 3.1.0 Use add_query_arg() instead.
91
- *
92
- * @param string $url
93
- * @return string $return_url
94
- */
95
- function wpmem_chk_qstr( $url = null ) {
96
- wpmem_write_log( "wpmem_chk_qstr() is deprecated as of WP-Members 3.1.0. Use add_query_arg() instead" );
97
- $permalink = get_option( 'permalink_structure' );
98
- if ( ! $permalink ) {
99
- $url = ( ! $url ) ? get_option( 'home' ) . "/?" . $_SERVER['QUERY_STRING'] : $url;
100
- $return_url = $url . "&";
101
- } else {
102
- $url = ( ! $url ) ? get_permalink() : $url;
103
- $return_url = $url . "?";
104
- }
105
- return $return_url;
106
- }
107
- endif;
108
-
109
-
110
- if ( ! function_exists( 'wpmem_generatePassword' ) ):
111
- /**
112
- * Generates a random password.
113
- *
114
- * @since 2.0.0
115
- * @deprecated Unknown Use wp_generate_password() instead.
116
- *
117
- * @return string The random password.
118
- */
119
- function wpmem_generatePassword() {
120
- wpmem_write_log( "WP-Members function wpmem_generatePassword() is deprecated. Use wp_generate_password() instead" );
121
- return substr( md5( uniqid( microtime() ) ), 0, 7 );
122
- }
123
- endif;
124
-
125
-
126
  if ( ! function_exists( 'wpmem_texturize' ) ):
127
  /**
128
  * Overrides the wptexturize filter.
@@ -131,6 +66,8 @@ if ( ! function_exists( 'wpmem_texturize' ) ):
131
  *
132
  * @since 2.6.4
133
  *
 
 
134
  * @param string $content
135
  * @return string $new_content
136
  */
@@ -287,39 +224,6 @@ function wpmem_do_excerpt( $content ) {
287
  endif;
288
 
289
 
290
- if ( ! function_exists( 'wpmem_test_shortcode' ) ):
291
- /**
292
- * Tests $content for the presence of the [wp-members] shortcode.
293
- *
294
- * @since 2.6.0
295
- * @deprecated 3.1.2 Use has_shortcode() instead.
296
- *
297
- * @global string $shortcode_tags
298
- * @return bool
299
- *
300
- * @example http://codex.wordpress.org/Function_Reference/get_shortcode_regex
301
- */
302
- function wpmem_test_shortcode( $content, $tag ) {
303
-
304
- wpmem_write_log( "wpmem_test_shortcode() is deprecated as of WP-Members 3.1.2. Use has_shortcode() instead." );
305
- global $shortcode_tags;
306
- if ( array_key_exists( $tag, $shortcode_tags ) ) {
307
- preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
308
- if ( empty( $matches ) ) {
309
- return false;
310
- }
311
-
312
- foreach ( $matches as $shortcode ) {
313
- if ( $tag === $shortcode[2] ) {
314
- return true;
315
- }
316
- }
317
- }
318
- return false;
319
- }
320
- endif;
321
-
322
-
323
  /**
324
  * Sets an array of user meta fields to be excluded from update/insert.
325
  *
@@ -385,4 +289,43 @@ function wpmem_write_log ( $log ) {
385
  }
386
  }
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  // End of file.
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at http://rocketgeek.com
10
+ * Copyright (c) 2006-2017 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @subpackage WP-Members Utility Functions
15
  * @author Chad Butler
16
+ * @copyright 2006-2017
17
  *
18
  * Functions included:
19
  * - wpmem_create_formfield
 
 
 
20
  * - wpmem_texturize
21
  * - wpmem_enqueue_style
22
  * - wpmem_do_excerpt
 
23
  * - wpmem_get_excluded_meta
24
  * - wpmem_use_ssl
25
  * - wpmem_wp_reserved_terms
58
  endif;
59
 
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  if ( ! function_exists( 'wpmem_texturize' ) ):
62
  /**
63
  * Overrides the wptexturize filter.
66
  *
67
  * @since 2.6.4
68
  *
69
+ * @todo Possibly deprecate or severely alter this process as its need may be obsolete.
70
+ *
71
  * @param string $content
72
  * @return string $new_content
73
  */
224
  endif;
225
 
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  /**
228
  * Sets an array of user meta fields to be excluded from update/insert.
229
  *
289
  }
290
  }
291
 
292
+ /**
293
+ * Convert form tag.
294
+ *
295
+ * @todo This is temporary to handle form tag conversion.
296
+ *
297
+ * @since 3.1.7
298
+ *
299
+ * @param string $tag
300
+ * @return string $tag
301
+ */
302
+ function wpmem_convert_tag( $tag ) {
303
+ switch ( $tag ) {
304
+ case 'new':
305
+ return 'register';
306
+ break;
307
+ case 'edit':
308
+ case 'update':
309
+ return 'profile';
310
+ break;
311
+ case 'wp':
312
+ case 'wp_validate':
313
+ case 'wp_finalize':
314
+ return 'register_wp';
315
+ break;
316
+ case 'dashboard_profile':
317
+ case 'dashboard_profile_update':
318
+ return 'profile_dashboard';
319
+ break;
320
+ case 'admin_profile':
321
+ case 'admin_profile_update':
322
+ return 'profile_admin';
323
+ break;
324
+ default:
325
+ return $tag;
326
+ break;
327
+ }
328
+ return $tag;
329
+ }
330
+
331
  // End of file.
inc/wp-registration.php CHANGED
@@ -8,12 +8,12 @@
8
  *
9
  * This file is part of the WP-Members plugin by Chad Butler
10
  * You can find out more about this plugin at http://rocketgeek.com
11
- * Copyright (c) 2006-2016 Chad Butler
12
  * WP-Members(tm) is a trademark of butlerblog.com
13
  *
14
  * @package WP-Members
15
  * @author Chad Butler
16
- * @copyright 2006-2016
17
  *
18
  * Functions Included:
19
  * - wpmem_do_wp_register_form
@@ -31,7 +31,7 @@
31
  function wpmem_do_wp_register_form() {
32
 
33
  global $wpmem;
34
- $wpmem_fields = wpmem_fields();
35
 
36
  // Check if this is WooCommerce account page.
37
  $is_woo = false;
@@ -194,7 +194,7 @@ function wpmem_do_wp_newuser_form() {
194
  global $wpmem;
195
  echo '<table class="form-table"><tbody>';
196
 
197
- $wpmem_fields = wpmem_fields();
198
  $exclude = wpmem_get_excluded_meta( 'register' );
199
 
200
  foreach ( $wpmem_fields as $meta_key => $field ) {
8
  *
9
  * This file is part of the WP-Members plugin by Chad Butler
10
  * You can find out more about this plugin at http://rocketgeek.com
11
+ * Copyright (c) 2006-2017 Chad Butler
12
  * WP-Members(tm) is a trademark of butlerblog.com
13
  *
14
  * @package WP-Members
15
  * @author Chad Butler
16
+ * @copyright 2006-2017
17
  *
18
  * Functions Included:
19
  * - wpmem_do_wp_register_form
31
  function wpmem_do_wp_register_form() {
32
 
33
  global $wpmem;
34
+ $wpmem_fields = wpmem_fields( 'wp' );
35
 
36
  // Check if this is WooCommerce account page.
37
  $is_woo = false;
194
  global $wpmem;
195
  echo '<table class="form-table"><tbody>';
196
 
197
+ $wpmem_fields = wpmem_fields( 'add_new' );
198
  $exclude = wpmem_get_excluded_meta( 'register' );
199
 
200
  foreach ( $wpmem_fields as $meta_key => $field ) {
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: cbutlerjr
3
  Tags: access, authentication, content, login, member, membership, password, protect, register, registration, restriction, subscriber
4
  Requires at least: 3.6
5
- Tested up to: 4.7.0
6
- Stable tag: 3.1.6.3
7
  License: GPLv2
8
 
9
  WP-Members&trade; is a free membership management framework for WordPress&reg; that restricts content to registered users.
@@ -112,8 +112,7 @@ Premium priority support is available at the plugin's site [RocketGeek.com](http
112
 
113
  == Upgrade Notice ==
114
 
115
- WP-Members 3.1.6.3 fixes some invalid characters in certain files in the wordpress.org repo version.
116
- WP-Members 3.1.6 is primarily a settings update. See changelog for important details. Minimum WP version is 3.6.
117
 
118
  == Screenshots ==
119
 
@@ -136,20 +135,35 @@ WP-Members 3.1.6 is primarily a settings update. See changelog for important det
136
 
137
  == Changelog ==
138
 
139
- = 3.1.6.3 =
140
-
141
- * Fixes some invalid characters in the wordpress.org repo version of the plugin that seem to have crept in during the 3.1.6.2 commit.
142
- * Applies some admin strings for translation.
143
- * Notes WordPress 4.7 compatibility.
144
-
145
- = 3.1.6.2 =
146
-
147
- * Applies style properties for the remember me checkbox label to the default stylesheets. The label tag was added to this text in 3.1.6 (see below).
148
-
149
- = 3.1.6.1 =
150
-
151
- * Fixes issue with displaying checkbox state on the admin user profile screen.
152
- * Fixes issue with auto excerpt when excerpts are displayed on single posts/pages.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  = 3.1.6 =
155
 
@@ -174,6 +188,10 @@ WP-Members 3.1.6 is primarily a settings update. See changelog for important det
174
  * Custom field term "Option Name" changed to "Meta Key" for clarity.
175
  * Marked required custom field properties as required in Add/Edit Field dialogs.
176
  * Changed redirect_to process to escape the url with esc_url_raw rather than esc_url, otherwise query string variables do not get handled correctly.
 
 
 
 
177
 
178
  = 3.1.5 =
179
 
2
  Contributors: cbutlerjr
3
  Tags: access, authentication, content, login, member, membership, password, protect, register, registration, restriction, subscriber
4
  Requires at least: 3.6
5
+ Tested up to: 4.7.3
6
+ Stable tag: 3.1.7
7
  License: GPLv2
8
 
9
  WP-Members&trade; is a free membership management framework for WordPress&reg; that restricts content to registered users.
112
 
113
  == Upgrade Notice ==
114
 
115
+ WP-Members 3.1.7 is a major update. There are no database changes (rollback is possible). See changelog for important details. Minimum WP version is 3.6.
 
116
 
117
  == Screenshots ==
118
 
135
 
136
  == Changelog ==
137
 
138
+ = 3.1.7 =
139
+
140
+ * API updates: added wpmem_is_user_activated().
141
+ * API updates: wpmem_is_reg_page() added default of current page ID.
142
+ * API updates: wpmem_current_url() added check for query string.
143
+ * API updates: Added wpmem_fields filter to wpmem_fields().
144
+ * API updates: Added wpmem_current_post_id() and wpmem_form_label() functions.
145
+ * API updates: Added new [wpmem_avatar], [wpmem_login_link], and [wpmem_register_link] shortcodes.
146
+ * API updates: Added filter option in user export to decode html entities in user fields.
147
+ * API updates: Added wpmem_get_action action hook when wpmem_a is loaded.
148
+ * All admin dependencies and actions/filters loaded in admin api object.
149
+ * Corrected issue in forms function were RS Captcha had empty div wrapper variable.
150
+ * Removed deprecated functions wpmem_load_admin_js(), wpmem_test_shortcode(), and wpmem_generatePassword().
151
+ * Moved remaining deprecated functions to new inc/deprecated.php.
152
+ * Added successful registration message on page if nonce validates (for reg redirects).
153
+ * Added User object class, handling login, logout, register.
154
+ * Added buffering to login form and widget to allow do_login action results to be displayed (such as 3rd party login captcha).
155
+ * Added support for WP's login_redirect filter (loads before wpmem_login_redirect).
156
+ * Added a div wrapper for post restricted message.
157
+ * Added initial form support for HTML5 number input, & min, max, title, and pattern attributes (placeholder support was added in 3.1.6).
158
+ * Updated wpmem_admin_update() to exit if there is no user ID.
159
+ * Updated admin notification email to translate field labels.
160
+ * Updated login form links and filters to a single process (was one for each).
161
+ * Updated WP Registration finalize process.
162
+ * Moved form building functions to forms object class.
163
+ * Deprecated wpmem_register_fields_arr filter (Use wpmem_fields instead).
164
+ * Removing the wpautop() function is now optional rather than default.
165
+ * Fixed load fields error checking, install function now correctly returns defaults.
166
+ * Changed password reset and password change to use wp_set_password() for improved performance with caching.
167
 
168
  = 3.1.6 =
169
 
188
  * Custom field term "Option Name" changed to "Meta Key" for clarity.
189
  * Marked required custom field properties as required in Add/Edit Field dialogs.
190
  * Changed redirect_to process to escape the url with esc_url_raw rather than esc_url, otherwise query string variables do not get handled correctly.
191
+ * Fixes issue with displaying checkbox state on the admin user profile screen.
192
+ * Fixes issue with auto excerpt when excerpts are displayed on single posts/pages.
193
+ * Applies style properties for the remember me checkbox label to the default stylesheets. The label tag was added to this text in 3.1.6 (see below).
194
+ * Applies some admin strings for translation.
195
 
196
  = 3.1.5 =
197
 
uninstall.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  */
16
 
17
  // If uninstall is not called from WordPress, kill the uninstall.
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  */
16
 
17
  // If uninstall is not called from WordPress, kill the uninstall.
wp-members-install.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  *
16
  * Functions included:
17
  * - wpmem_do_install
@@ -502,24 +502,23 @@ function wpmem_install_settings() {
502
  * Installs default fields.
503
  *
504
  * @since 3.1.5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
  */
506
  function wpmem_install_fields() {
507
- /*
508
- * Field array elements:
509
- *
510
- * array(
511
- * order,
512
- * label,
513
- * optionname,
514
- * type,
515
- * display,
516
- * required,
517
- * native,
518
- * checked value,
519
- * checked by default,
520
- * );
521
- */
522
- $wpmem_fields_options_arr = array(
523
  array( 1, 'First Name', 'first_name', 'text', 'y', 'y', 'y' ),
524
  array( 2, 'Last Name', 'last_name', 'text', 'y', 'y', 'y' ),
525
  array( 3, 'Address 1', 'addr1', 'text', 'y', 'y', 'n' ),
@@ -537,8 +536,8 @@ function wpmem_install_fields() {
537
  array( 15, 'Confirm Password', 'confirm_password', 'password', 'n', 'n', 'n' ),
538
  array( 16, 'TOS', 'tos', 'checkbox', 'n', 'n', 'n', 'agree', 'n' ),
539
  );
540
-
541
- update_option( 'wpmembers_fields', $wpmem_fields_options_arr, '', 'yes' ); // using update_option to allow for forced update
542
  }
543
 
544
  /**
@@ -558,10 +557,8 @@ function wpmem_install_dialogs() {
558
  'pwdreseterr' => "Either the username or email address do not exist in our records.",
559
  'pwdresetsuccess' => "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.",
560
  );
561
-
562
  // Insert TOS dialog placeholder.
563
  $dummy_tos = "Put your TOS (Terms of Service) text here. You can use HTML markup.";
564
-
565
  update_option( 'wpmembers_tos', $dummy_tos );
566
  update_option( 'wpmembers_dialogs', $wpmem_dialogs_arr, '', 'yes' ); // using update_option to allow for forced update
567
  }
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  *
16
  * Functions included:
17
  * - wpmem_do_install
502
  * Installs default fields.
503
  *
504
  * @since 3.1.5
505
+ *
506
+ * @return array $fields {
507
+ * @type array {
508
+ * order,
509
+ * label,
510
+ * meta key,
511
+ * type,
512
+ * display,
513
+ * required,
514
+ * native,
515
+ * checked value,
516
+ * checked by default,
517
+ * }
518
+ * }
519
  */
520
  function wpmem_install_fields() {
521
+ $fields = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  array( 1, 'First Name', 'first_name', 'text', 'y', 'y', 'y' ),
523
  array( 2, 'Last Name', 'last_name', 'text', 'y', 'y', 'y' ),
524
  array( 3, 'Address 1', 'addr1', 'text', 'y', 'y', 'n' ),
536
  array( 15, 'Confirm Password', 'confirm_password', 'password', 'n', 'n', 'n' ),
537
  array( 16, 'TOS', 'tos', 'checkbox', 'n', 'n', 'n', 'agree', 'n' ),
538
  );
539
+ update_option( 'wpmembers_fields', $fields, '', 'yes' ); // using update_option to allow for forced update
540
+ return $fields;
541
  }
542
 
543
  /**
557
  'pwdreseterr' => "Either the username or email address do not exist in our records.",
558
  'pwdresetsuccess' => "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.",
559
  );
 
560
  // Insert TOS dialog placeholder.
561
  $dummy_tos = "Put your TOS (Terms of Service) text here. You can use HTML markup.";
 
562
  update_option( 'wpmembers_tos', $dummy_tos );
563
  update_option( 'wpmembers_dialogs', $wpmem_dialogs_arr, '', 'yes' ); // using update_option to allow for forced update
564
  }
wp-members-tos.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
- * Copyright (c) 2006-2016 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2016
15
  */
16
 
17
  define ( 'WP_USE_THEMES', false );
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at http://rocketgeek.com
9
+ * Copyright (c) 2006-2017 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2017
15
  */
16
 
17
  define ( 'WP_USE_THEMES', false );
wp-members.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-Members
4
  Plugin URI: http://rocketgeek.com
5
  Description: WP access restriction and user registration. For more information on plugin features, refer to <a href="http://rocketgeek.com/plugins/wp-members/users-guide/">the online Users Guide</a>. A <a href="http://rocketgeek.com/plugins/wp-members/quick-start-guide/">Quick Start Guide</a> is also available. WP-Members(tm) is a trademark of butlerblog.com.
6
- Version: 3.1.6.3
7
  Author: Chad Butler
8
  Author URI: http://butlerblog.com/
9
  Text Domain: wp-members
@@ -13,7 +13,7 @@ License: GPLv2
13
 
14
 
15
  /*
16
- Copyright (c) 2006-2016 Chad Butler
17
 
18
  The name WP-Members(tm) is a trademark of butlerblog.com
19
 
@@ -62,7 +62,7 @@ License: GPLv2
62
 
63
 
64
  // Initialize constants.
65
- define( 'WPMEM_VERSION', '3.1.6.3' );
66
  define( 'WPMEM_DEBUG', false );
67
  define( 'WPMEM_DIR', plugin_dir_url ( __FILE__ ) );
68
  define( 'WPMEM_PATH', plugin_dir_path( __FILE__ ) );
@@ -122,47 +122,6 @@ function wpmem_init() {
122
  }
123
 
124
 
125
- /**
126
- * Scripts for admin panels.
127
- *
128
- * Determines which scripts to load and actions to use based on the
129
- * current users capabilities.
130
- *
131
- * @since 2.5.2
132
- * @since 3.1.0 Added admin api object.
133
- *
134
- * @global object $wpmem WP_Members object class.
135
- */
136
- function wpmem_chk_admin() {
137
-
138
- global $wpmem;
139
-
140
- /**
141
- * Fires before initialization of admin options.
142
- *
143
- * @since 2.9.0
144
- */
145
- do_action( 'wpmem_pre_admin_init' );
146
-
147
- /**
148
- * Load the admin api class.
149
- *
150
- * @since 3.1
151
- */
152
- include_once( WPMEM_PATH . 'admin/includes/class-wp-members-admin-api.php' );
153
-
154
- // Initilize the admin api.
155
- $wpmem->load_admin_api();
156
-
157
- /**
158
- * Fires after initialization of admin options.
159
- *
160
- * @since 2.9.0
161
- */
162
- do_action( 'wpmem_after_admin_init' );
163
- }
164
-
165
-
166
  /**
167
  * Adds the plugin options page and JavaScript.
168
  *
3
  Plugin Name: WP-Members
4
  Plugin URI: http://rocketgeek.com
5
  Description: WP access restriction and user registration. For more information on plugin features, refer to <a href="http://rocketgeek.com/plugins/wp-members/users-guide/">the online Users Guide</a>. A <a href="http://rocketgeek.com/plugins/wp-members/quick-start-guide/">Quick Start Guide</a> is also available. WP-Members(tm) is a trademark of butlerblog.com.
6
+ Version: 3.1.7
7
  Author: Chad Butler
8
  Author URI: http://butlerblog.com/
9
  Text Domain: wp-members
13
 
14
 
15
  /*
16
+ Copyright (c) 2006-2017 Chad Butler
17
 
18
  The name WP-Members(tm) is a trademark of butlerblog.com
19
 
62
 
63
 
64
  // Initialize constants.
65
+ define( 'WPMEM_VERSION', '3.1.7' );
66
  define( 'WPMEM_DEBUG', false );
67
  define( 'WPMEM_DIR', plugin_dir_url ( __FILE__ ) );
68
  define( 'WPMEM_PATH', plugin_dir_path( __FILE__ ) );
122
  }
123
 
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  /**
126
  * Adds the plugin options page and JavaScript.
127
  *