WP-Members Membership Plugin - Version 3.1.8

Version Description

  • Added new native registration handling to accommodate WooCommerce 3.0.
  • Added support for user file upload on admin/dashboard profile.
  • Added meta_key/meta_value attribute to [wpmem_logged_in] shortcode.
  • Added wpmem_user_has_meta() API function.
  • Updated post editor shortcode button javascript to include new(er) shortcodes.
  • Fixed WP-Members user profile shortcode to only display logged in content (by shortcode) if the wpmem_a 'action' is not set (i.e. logged in content only displays if page is in "member links" state).
  • Fixed register link in login form to prevent link from displaying if login form is displayed along with the registration form (standard configuration).
  • Improved multisite support, including revisions to load all admin dependencies for administrator role, not just super admin. Dependency load role requirement is filterable.
  • Improved line break stripping process in form builder to allow for line breaks in textarea fields.
  • Improved field shortcode for textarea fields to display line breaks.
  • Deprecated old wpmem_do_sc_pages() function, updated wpmem_sc_user_profile().
  • Removed $SERVER['REQUEST_URI'] from all admin tab form action attributes. Replaced with new wpmemadmin_form_post_url() API function.
  • Fields Tab: ground-up rebuild to utilize WP_List_Table and jquery sorting UI.
  • Fields Tab: improved field add/edit screen: return link at bottom of page, display current field upon successful form submission, success message include return link.
  • Fields Tab: added support for HTML5 field types: number, date.
  • Fields Tab: added support for HTML5 field attributes: placeholder, pattern (regex), title, min, max.
Download this release

Release Info

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

Code changes from version 3.1.7 to 3.1.8

admin/admin.php CHANGED
@@ -26,16 +26,6 @@
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
- }
38
-
39
 
40
  /**
41
  * Filter to add link to settings from plugin panel.
@@ -157,9 +147,6 @@ function wpmem_admin_do_tab( $tab ) {
157
  case 'options' :
158
  wpmem_a_build_options();
159
  break;
160
- case 'fields' :
161
- wpmem_a_build_fields();
162
- break;
163
  case 'dialogs' :
164
  wpmem_a_build_dialogs();
165
  break;
@@ -206,12 +193,6 @@ function wpmem_admin_action( $action ) {
206
  $did_update = ( 'update_cpts' == $action ) ? wpmem_update_cpts() : wpmem_update_options();
207
  break;
208
 
209
- case 'update_fields':
210
- case 'add_field':
211
- case 'edit_field':
212
- $did_update = wpmem_update_fields( $action );
213
- break;
214
-
215
  case 'update_dialogs':
216
  $did_update = wpmem_update_dialogs();
217
  break;
26
  * - wpmem_admin_enqueue_scripts
27
  */
28
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  /**
31
  * Filter to add link to settings from plugin panel.
147
  case 'options' :
148
  wpmem_a_build_options();
149
  break;
 
 
 
150
  case 'dialogs' :
151
  wpmem_a_build_dialogs();
152
  break;
193
  $did_update = ( 'update_cpts' == $action ) ? wpmem_update_cpts() : wpmem_update_options();
194
  break;
195
 
 
 
 
 
 
 
196
  case 'update_dialogs':
197
  $did_update = wpmem_update_dialogs();
198
  break;
admin/css/admin.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
 
@@ -50,4 +50,11 @@
50
 
51
  .req {
52
  color: #f00;
53
- }
 
 
 
 
 
 
 
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
 
50
 
51
  .req {
52
  color: #f00;
53
+ }
54
+
55
+ #the-list {
56
+ cursor: move;
57
+ }
58
+ #sort {
59
+ width: 24px;
60
+ }
admin/includes/api.php CHANGED
@@ -83,3 +83,18 @@ function wpmem_is_tab( $tab ) {
83
  function wpmem_admin_user_profile( $user_id ) {
84
  return add_query_arg( 'user_id', $user_id, admin_url( 'user-edit.php' ) );
85
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  function wpmem_admin_user_profile( $user_id ) {
84
  return add_query_arg( 'user_id', $user_id, admin_url( 'user-edit.php' ) );
85
  }
86
+
87
+ /**
88
+ * Wrapper for form_post_url().
89
+ *
90
+ * @since 3.1.8
91
+ *
92
+ * @global object $wpmem The WP_Members Object.
93
+ * @param string $tab The plugin tab being displayed.
94
+ * @param mixed $args Array of additional arguments|boolean. Default: false.
95
+ * @return string $url
96
+ */
97
+ function wpmem_admin_form_post_url( $args = false ) {
98
+ global $wpmem;
99
+ return $wpmem->admin->form_post_url( $args );
100
+ }
admin/includes/class-wp-members-admin-api.php CHANGED
@@ -67,27 +67,44 @@ class WP_Members_Admin_API {
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' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  require_once( WPMEM_PATH . 'admin/admin.php' );
72
  }
73
- if ( current_user_can( 'edit_users' ) ) {
74
- require_once( WPMEM_PATH . 'admin/admin.php' );
75
  require_once( WPMEM_PATH . 'admin/user-profile.php' );
76
  }
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' );
 
83
  require_once( WPMEM_PATH . 'admin/dialogs.php' );
84
  }
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
  }
@@ -109,12 +126,14 @@ class WP_Members_Admin_API {
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' );
@@ -462,6 +481,33 @@ class WP_Members_Admin_API {
462
  $this->current_form_fields = wpmem_fields();
463
  }
464
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
  } // End of WP_Members_Admin_API class.
466
 
467
  // End of file.
67
  * @since 3.1.7 Loads all admin dependent files.
68
  */
69
  function load_dependencies() {
70
+
71
+ // Default permissions for loading admin dependencies.
72
+ $defaults = array(
73
+ 'main' => 'edit_theme_options',
74
+ 'users' => 'list_users',
75
+ 'options' => 'manage_options',
76
+ 'posts' => 'edit_posts',
77
+ );
78
+ /**
79
+ * Filter permission defaults.
80
+ *
81
+ * @since 3.1.8
82
+ *
83
+ * @param array $defaults
84
+ *
85
+ * @todo Still needs final evaluation.
86
+ */
87
+ $permissions = apply_filters( 'wpmem_load_admin_permissions', $defaults );
88
+
89
+ if ( current_user_can( $permissions['main'] ) ) {
90
  require_once( WPMEM_PATH . 'admin/admin.php' );
91
  }
92
+ if ( current_user_can( $permissions['users'] ) ) {
93
+ require_once( WPMEM_PATH . 'admin/users.php' );
94
  require_once( WPMEM_PATH . 'admin/user-profile.php' );
95
  }
96
+ if ( current_user_can( $permissions['options'] ) ) {
97
  require_once( WPMEM_PATH . 'admin/tab-options.php' );
98
  require_once( WPMEM_PATH . 'admin/tab-fields.php' );
99
  require_once( WPMEM_PATH . 'admin/tab-emails.php' );
100
  require_once( WPMEM_PATH . 'admin/tab-captcha.php' );
101
  require_once( WPMEM_PATH . 'admin/tab-about.php' );
102
+ require_once( WPMEM_PATH . 'admin/tab-dialogs.php' );
103
  require_once( WPMEM_PATH . 'admin/dialogs.php' );
104
  }
105
+ if ( current_user_can( $permissions['posts'] ) ) {
106
  require_once( WPMEM_PATH . 'admin/post.php' );
107
  }
 
 
 
108
  require_once( WPMEM_PATH . 'admin/includes/api.php' );
109
  include_once( WPMEM_PATH . 'inc/wp-registration.php' );
110
  }
126
  add_action( 'wpmem_admin_do_tab', 'wpmem_a_about_tab', 999, 1 );
127
 
128
  // If user has a role that cannot edit users, set profile actions for non-admins.
129
+ if ( ! current_user_can( 'edit_users' ) ) {
130
  // User actions and filters.
131
+ add_action( 'user_edit_form_tag', 'wpmem_user_profile_multipart' );
132
  add_action( 'show_user_profile', 'wpmem_user_profile' );
133
  add_action( 'edit_user_profile', 'wpmem_user_profile' );
134
  add_action( 'profile_update', 'wpmem_profile_update' );
135
  } else {
136
+ add_action( 'user_edit_form_tag', 'wpmem_user_profile_multipart' );
137
  add_action( 'show_user_profile', 'wpmem_admin_fields' );
138
  add_action( 'edit_user_profile', 'wpmem_admin_fields' );
139
  add_action( 'profile_update', 'wpmem_admin_update' );
481
  $this->current_form_fields = wpmem_fields();
482
  }
483
 
484
+ /**
485
+ * Build admin panel form action url.
486
+ *
487
+ * @since 3.1.8
488
+ *
489
+ * @global string $pagenow
490
+ * @global string $plugin_page
491
+ * @global object $wpmem The WP_Members Object.
492
+ * @param mixed $args Array of additional arguments|boolean. Default: false.
493
+ * @return string $url
494
+ */
495
+ function form_post_url( $args = false ) {
496
+ global $pagenow, $plugin_page, $wpmem;
497
+ $tab = wpmem_get( 'tab', false, 'get' );
498
+ $params = array( 'page' => $plugin_page );
499
+ if ( $tab ) {
500
+ $params['tab'] = $tab;
501
+ }
502
+ if ( $args ) {
503
+ foreach( $args as $key => $val ) {
504
+ $params[ $key ] = $val;
505
+ }
506
+ }
507
+ $url = add_query_arg( $params, admin_url( $pagenow ) );
508
+ return $url;
509
+ }
510
+
511
  } // End of WP_Members_Admin_API class.
512
 
513
  // End of file.
admin/js/admin.js CHANGED
@@ -5,369 +5,45 @@
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
- * TableDnD plugin for jQuery :
12
- * Copyright (c) Denis Howlett <denish@isocra.com>
13
- * Licensed like jQuery, see http://docs.jquery.com/License.
14
- *
15
- * table.add.row plugin for jQuery :
16
- * Copyright (c) C.F.Wong <cloudgen@ymail.com>
17
- * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
18
- *
19
- * @package WordPress
20
- * @subpackage WP-Members
21
  * @author Chad Butler
22
- * @copyright 2006-2015
23
- */
24
-
25
-
26
- /**
27
- * JS for field table DnD
28
- *
29
- * @since 2.6
30
  */
31
- (function($) {
32
- $(document).ready(function() {
33
-
34
- $("#wpmem-fields").tableDnD({
35
- onDragClass: "wpmem_tbl_drag",
36
-
37
- onDrop: function(table, row) {
38
- var data = {
39
- action: 'wpmem_a_field_reorder',
40
- orderstring: $.tableDnD.serialize()
41
- }
42
-
43
- $.post( ajaxurl, data, function(response) {
44
- // alert(response);
45
- })
46
- }
47
- });
48
- });
49
- })(jQuery);
50
-
51
-
52
- /**
53
- * TableDnD plug-in for JQuery, allows you to drag and drop table rows
54
- * You can set up various options to control how the system will work
55
- * Copyright (c) Denis Howlett <denish@isocra.com>
56
- * Licensed like jQuery, see http://docs.jquery.com/License.
57
- */
58
- jQuery.tableDnD = {
59
- /** Keep hold of the current table being dragged */
60
- currentTable : null,
61
- /** Keep hold of the current drag object if any */
62
- dragObject: null,
63
- /** The current mouse offset */
64
- mouseOffset: null,
65
- /** Remember the old value of Y so that we don't do too much processing */
66
- oldY: 0,
67
-
68
- /** Actually build the structure */
69
- build: function(options) {
70
- // Set up the defaults if any
71
-
72
- this.each(function() {
73
- // This is bound to each matching table, set up the defaults and override with user options
74
- this.tableDnDConfig = jQuery.extend({
75
- onDragStyle: null,
76
- onDropStyle: null,
77
- // Add in the default class for whileDragging
78
- onDragClass: "tDnD_whileDrag",
79
- onDrop: null,
80
- onDragStart: null,
81
- scrollAmount: 5,
82
- serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
83
- serializeParamName: null, // If you want to specify another parameter name instead of the table ID
84
- dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
85
- }, options || {});
86
- // Now make the rows draggable
87
- jQuery.tableDnD.makeDraggable(this);
88
- });
89
-
90
- // Now we need to capture the mouse up and mouse move event
91
- // We can use bind so that we don't interfere with other event handlers
92
- jQuery(document)
93
- .bind('mousemove', jQuery.tableDnD.mousemove)
94
- .bind('mouseup', jQuery.tableDnD.mouseup);
95
-
96
- // Don't break the chain
97
- return this;
98
- },
99
-
100
- /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
101
- makeDraggable: function(table) {
102
- var config = table.tableDnDConfig;
103
- if (table.tableDnDConfig.dragHandle) {
104
- // We only need to add the event to the specified cells
105
- var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
106
- cells.each(function() {
107
- // The cell is bound to "this"
108
- jQuery(this).mousedown(function(ev) {
109
- jQuery.tableDnD.dragObject = this.parentNode;
110
- jQuery.tableDnD.currentTable = table;
111
- jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
112
- if (config.onDragStart) {
113
- // Call the onDrop method if there is one
114
- config.onDragStart(table, this);
115
- }
116
- return false;
117
- });
118
- })
119
- } else {
120
- // For backwards compatibility, we add the event to the whole row
121
- var rows = jQuery("tr", table); // get all the rows as a wrapped set
122
- rows.each(function() {
123
- // Iterate through each row, the row is bound to "this"
124
- var row = jQuery(this);
125
- if (! row.hasClass("nodrag")) {
126
- row.mousedown(function(ev) {
127
- if (ev.target.tagName == "TD") {
128
- jQuery.tableDnD.dragObject = this;
129
- jQuery.tableDnD.currentTable = table;
130
- jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
131
- if (config.onDragStart) {
132
- // Call the onDrop method if there is one
133
- config.onDragStart(table, this);
134
- }
135
- return false;
136
- }
137
- }).css("cursor", "move"); // Store the tableDnD object
138
- }
139
  });
140
  }
141
- },
142
-
143
- updateTables: function() {
144
- this.each(function() {
145
- // this is now bound to each matching table
146
- if (this.tableDnDConfig) {
147
- jQuery.tableDnD.makeDraggable(this);
148
- }
149
- })
150
- },
151
-
152
- /** Get the mouse coordinates from the event (allowing for browser differences) */
153
- mouseCoords: function(ev){
154
- if(ev.pageX || ev.pageY){
155
- return {x:ev.pageX, y:ev.pageY};
156
- }
157
- return {
158
- x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
159
- y:ev.clientY + document.body.scrollTop - document.body.clientTop
160
- };
161
- },
162
-
163
- /** Given a target element and a mouse event, get the mouse offset from that element.
164
- To do this we need the element's position and the mouse position */
165
- getMouseOffset: function(target, ev) {
166
- ev = ev || window.event;
167
-
168
- var docPos = this.getPosition(target);
169
- var mousePos = this.mouseCoords(ev);
170
- return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
171
- },
172
-
173
- /** Get the position of an element by going up the DOM tree and adding up all the offsets */
174
- getPosition: function(e){
175
- var left = 0;
176
- var top = 0;
177
- /** Safari fix -- thanks to Luis Chato for this! */
178
- if (e.offsetHeight == 0) {
179
- /** Safari 2 doesn't correctly grab the offsetTop of a table row
180
- this is detailed here:
181
- http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
182
- the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
183
- note that firefox will return a text node as a first child, so designing a more thorough
184
- solution may need to take that into account, for now this seems to work in firefox, safari, ie */
185
- e = e.firstChild; // a table cell
186
- }
187
-
188
- while (e.offsetParent){
189
- left += e.offsetLeft;
190
- top += e.offsetTop;
191
- e = e.offsetParent;
192
- }
193
-
194
- left += e.offsetLeft;
195
- top += e.offsetTop;
196
-
197
- return {x:left, y:top};
198
- },
199
-
200
- mousemove: function(ev) {
201
- if (jQuery.tableDnD.dragObject == null) {
202
- return;
203
- }
204
-
205
- var dragObj = jQuery(jQuery.tableDnD.dragObject);
206
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
207
- var mousePos = jQuery.tableDnD.mouseCoords(ev);
208
- var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
209
- //auto scroll the window
210
- var yOffset = window.pageYOffset;
211
- if (document.all) {
212
- // Windows version
213
- //yOffset=document.body.scrollTop;
214
- if (typeof document.compatMode != 'undefined' &&
215
- document.compatMode != 'BackCompat') {
216
- yOffset = document.documentElement.scrollTop;
217
- }
218
- else if (typeof document.body != 'undefined') {
219
- yOffset=document.body.scrollTop;
220
- }
221
-
222
- }
223
-
224
- if (mousePos.y-yOffset < config.scrollAmount) {
225
- window.scrollBy(0, -config.scrollAmount);
226
- } else {
227
- var windowHeight = window.innerHeight ? window.innerHeight
228
- : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
229
- if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
230
- window.scrollBy(0, config.scrollAmount);
231
- }
232
- }
233
-
234
-
235
- if (y != jQuery.tableDnD.oldY) {
236
- // work out if we're going up or down...
237
- var movingDown = y > jQuery.tableDnD.oldY;
238
- // update the old value
239
- jQuery.tableDnD.oldY = y;
240
- // update the style to show we're dragging
241
- if (config.onDragClass) {
242
- dragObj.addClass(config.onDragClass);
243
- } else {
244
- dragObj.css(config.onDragStyle);
245
- }
246
- // If we're over a row then move the dragged row to there so that the user sees the
247
- // effect dynamically
248
- var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
249
- if (currentRow) {
250
- // TODO worry about what happens when there are multiple TBODIES
251
- if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
252
- jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
253
- } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
254
- jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
255
- }
256
- }
257
- }
258
-
259
- return false;
260
- },
261
-
262
- /** We're only worried about the y position really, because we can only move rows up and down */
263
- findDropTargetRow: function(draggedRow, y) {
264
- var rows = jQuery.tableDnD.currentTable.rows;
265
- for (var i=0; i<rows.length; i++) {
266
- var row = rows[i];
267
- var rowY = this.getPosition(row).y;
268
- var rowHeight = parseInt(row.offsetHeight)/2;
269
- if (row.offsetHeight == 0) {
270
- rowY = this.getPosition(row.firstChild).y;
271
- rowHeight = parseInt(row.firstChild.offsetHeight)/2;
272
- }
273
- // Because we always have to insert before, we need to offset the height a bit
274
- if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
275
- // that's the row we're over
276
- // If it's the same as the current row, ignore it
277
- if (row == draggedRow) {return null;}
278
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
279
- if (config.onAllowDrop) {
280
- if (config.onAllowDrop(draggedRow, row)) {
281
- return row;
282
- } else {
283
- return null;
284
- }
285
- } else {
286
- // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
287
- var nodrop = jQuery(row).hasClass("nodrop");
288
- if (! nodrop) {
289
- return row;
290
- } else {
291
- return null;
292
- }
293
- }
294
- return row;
295
- }
296
- }
297
- return null;
298
- },
299
-
300
- mouseup: function(e) {
301
- if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
302
- var droppedRow = jQuery.tableDnD.dragObject;
303
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
304
- // If we have a dragObject, then we need to release it,
305
- // The row will already have been moved to the right place so we just reset stuff
306
- if (config.onDragClass) {
307
- jQuery(droppedRow).removeClass(config.onDragClass);
308
- } else {
309
- jQuery(droppedRow).css(config.onDropStyle);
310
- }
311
- jQuery.tableDnD.dragObject = null;
312
- if (config.onDrop) {
313
- // Call the onDrop method if there is one
314
- config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
315
- }
316
- jQuery.tableDnD.currentTable = null; // let go of the table too
317
- }
318
- },
319
-
320
- serialize: function() {
321
- if (jQuery.tableDnD.currentTable) {
322
- return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
323
- } else {
324
- return "Error: No Table id set, you need to set an id on your table and every row";
325
- }
326
- },
327
-
328
- serializeTable: function(table) {
329
- var result = "";
330
- var tableId = table.id;
331
- var rows = table.rows;
332
- for (var i=0; i<rows.length; i++) {
333
- if (result.length > 0) result += "&";
334
- var rowId = rows[i].id;
335
- if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
336
- rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
337
- }
338
-
339
- result += tableId + '[]=' + rowId;
340
- }
341
- return result;
342
- },
343
-
344
- serializeTables: function() {
345
- var result = "";
346
- this.each(function() {
347
- // this is now bound to each matching table
348
- result += jQuery.tableDnD.serializeTable(this);
349
- });
350
- return result;
351
- }
352
-
353
- }
354
-
355
- jQuery.fn.extend(
356
- {
357
- tableDnD : jQuery.tableDnD.build,
358
- tableDnDUpdate : jQuery.tableDnD.updateTables,
359
- tableDnDSerialize: jQuery.tableDnD.serializeTables
360
- }
361
- );
362
-
363
- /** END TableDnD plugin */
364
 
365
 
366
  /**
367
  * JS for displaying custom url for:
368
- * * Profile page
369
- * * Register page
370
- * * Custom stylesheet
371
  *
372
  * @since 2.9.6
373
  */
@@ -424,6 +100,8 @@ jQuery.fn.extend(
424
  */
425
  (function($) {
426
  $(document).ready(function() {
 
 
427
  $("#wpmem_checkbox_info").hide();
428
  $("#wpmem_dropdown_info").hide();
429
  $("#wpmem_file_info").hide();
@@ -432,6 +110,36 @@ jQuery.fn.extend(
432
  });
433
  $(document).ready(function() {
434
  $("#wpmem_field_type_select").change(function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  if ($("#wpmem_field_type_select").val() == 'checkbox')
436
  $("#wpmem_checkbox_info").show();
437
  else
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 WP-Members
 
 
 
 
 
 
 
 
 
12
  * @author Chad Butler
13
+ * @copyright 2006-2017
 
 
 
 
 
 
 
14
  */
15
+
16
+
17
+ /**
18
+ * JS for forms field table drag-and-drop.
19
+ *
20
+ * @since 3.1.2
21
+ */
22
+ jQuery(document).ready(function($) {
23
+ $("#the-list").sortable({
24
+ items: '.list_item',
25
+ opacity: 0.6,
26
+ cursor: 'move',
27
+ axis: 'y',
28
+ update: function() {
29
+ var order = $(this).sortable('serialize') + '&action=wpmem_a_field_reorder';
30
+ $.post(ajaxurl, order, function(response) {
31
+ alert(response);
32
+ });
33
+ $('.list_item').each(function(i) {
34
+ $(this).data('id', i + 1); // updates the data object
35
+ $(this).attr('list_item', i + 1); // updates the attribute
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  });
37
  }
38
+ });
39
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
 
42
  /**
43
  * JS for displaying custom url for:
44
+ * - Profile page
45
+ * - Register page
46
+ * - Custom stylesheet
47
  *
48
  * @since 2.9.6
49
  */
100
  */
101
  (function($) {
102
  $(document).ready(function() {
103
+ $("#wpmem_allowhtml").hide();
104
+ $("#wpmem_min_max").hide();
105
  $("#wpmem_checkbox_info").hide();
106
  $("#wpmem_dropdown_info").hide();
107
  $("#wpmem_file_info").hide();
110
  });
111
  $(document).ready(function() {
112
  $("#wpmem_field_type_select").change(function() {
113
+ if ($("#wpmem_field_type_select").val() == 'text'
114
+ || $("#wpmem_field_type_select").val() == 'password'
115
+ || $("#wpmem_field_type_select").val() == 'email'
116
+ || $("#wpmem_field_type_select").val() == 'url'
117
+ || $("#wpmem_field_type_select").val() == 'number'
118
+ || $("#wpmem_field_type_select").val() == 'date'
119
+ || $("#wpmem_field_type_select").val() == 'textarea' )
120
+ $("#wpmem_placeholder").show();
121
+ else
122
+ $("#wpmem_placeholder").hide();
123
+ if ($("#wpmem_field_type_select").val() == 'text'
124
+ || $("#wpmem_field_type_select").val() == 'password'
125
+ || $("#wpmem_field_type_select").val() == 'email'
126
+ || $("#wpmem_field_type_select").val() == 'url'
127
+ || $("#wpmem_field_type_select").val() == 'number'
128
+ || $("#wpmem_field_type_select").val() == 'date' ) {
129
+ $("#wpmem_pattern").show();
130
+ $("#wpmem_title").show();
131
+ } else {
132
+ $("#wpmem_pattern").hide();
133
+ $("#wpmem_title").hide();
134
+ }
135
+ if ($("#wpmem_field_type_select").val() == 'textarea' )
136
+ $("#wpmem_allowhtml").show();
137
+ else
138
+ $("#wpmem_allowhtml").hide();
139
+ if ($("#wpmem_field_type_select").val() == 'number' || $("#wpmem_field_type_select").val() == 'date' )
140
+ $("#wpmem_min_max").show();
141
+ else
142
+ $("#wpmem_min_max").hide();
143
  if ($("#wpmem_field_type_select").val() == 'checkbox')
144
  $("#wpmem_checkbox_info").show();
145
  else
admin/js/shortcodes_tinymce_4.js CHANGED
@@ -54,28 +54,28 @@
54
  editor.insertContent('[wpmem_form register]');
55
  }
56
  },
57
- /*{
58
  text: "registration + redirect",
59
  onclick: function(){
60
  editor.insertContent('[wpmem_form register redirect_to="http://mysite.com/my-page/"]');
61
  }
62
- },*/
63
  {
64
  text: "registration + logged in content",
65
  onclick: function(){
66
  editor.insertContent('[wpmem_form register]<br />This displays when logged in<br />[/wpmem_form]');
67
  }
68
  },
69
- /*{
70
  text: "registration + redirect + content",
71
  onclick: function(){
72
  editor.insertContent('[wpmem_form register redirect_to="http://mysite.com/my-page/"]<br />This displays when logged in<br />[/wpmem_form]');
73
  }
74
- },*/
75
  ]
76
  },
77
  {
78
- text: 'Other Forms',
79
  menu: [
80
  {
81
  text: "User Profile Page",
@@ -133,7 +133,7 @@
133
  ]
134
  },
135
  {
136
- text: 'Login / Logout Links',
137
  menu: [
138
  {
139
  text: "basic logout link",
@@ -153,6 +153,30 @@
153
  editor.insertContent('[wpmem_loginout]');
154
  }
155
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  ]
157
  },
158
  {
@@ -167,6 +191,12 @@
167
  editor.insertContent('[wpmem_show_count label="Active Users: " key=active value=1]');
168
  }
169
  },
 
 
 
 
 
 
170
  ]
171
  }
172
  });
54
  editor.insertContent('[wpmem_form register]');
55
  }
56
  },
57
+ {
58
  text: "registration + redirect",
59
  onclick: function(){
60
  editor.insertContent('[wpmem_form register redirect_to="http://mysite.com/my-page/"]');
61
  }
62
+ },
63
  {
64
  text: "registration + logged in content",
65
  onclick: function(){
66
  editor.insertContent('[wpmem_form register]<br />This displays when logged in<br />[/wpmem_form]');
67
  }
68
  },
69
+ {
70
  text: "registration + redirect + content",
71
  onclick: function(){
72
  editor.insertContent('[wpmem_form register redirect_to="http://mysite.com/my-page/"]<br />This displays when logged in<br />[/wpmem_form]');
73
  }
74
+ },
75
  ]
76
  },
77
  {
78
+ text: 'User Profile',
79
  menu: [
80
  {
81
  text: "User Profile Page",
133
  ]
134
  },
135
  {
136
+ text: 'Links',
137
  menu: [
138
  {
139
  text: "basic logout link",
153
  editor.insertContent('[wpmem_loginout]');
154
  }
155
  },
156
+ {
157
+ text: "log in link",
158
+ onclick: function(){
159
+ editor.insertContent('[wpmem_login_link]');
160
+ }
161
+ },
162
+ {
163
+ text: "log in link + custom link text",
164
+ onclick: function(){
165
+ editor.insertContent('[wpmem_login_link]Link Text[/wpmem_login_link]');
166
+ }
167
+ },
168
+ {
169
+ text: "register link",
170
+ onclick: function(){
171
+ editor.insertContent('[wpmem_reg_link]');
172
+ }
173
+ },
174
+ {
175
+ text: "register link + custom link text",
176
+ onclick: function(){
177
+ editor.insertContent('[wpmem_reg_link]Link Text[/wpmem_reg_link]');
178
+ }
179
+ }
180
  ]
181
  },
182
  {
191
  editor.insertContent('[wpmem_show_count label="Active Users: " key=active value=1]');
192
  }
193
  },
194
+ {
195
+ text: 'User Avatar',
196
+ onclick: function(){
197
+ editor.insertContent('[wpmem_avatar]');
198
+ }
199
+ },
200
  ]
201
  }
202
  });
admin/tab-captcha.php CHANGED
@@ -52,7 +52,7 @@ function wpmem_a_build_captcha_options() {
52
 
53
  <h3><?php _e( 'Manage reCAPTCHA Options', 'wp-members' ); ?></h3>
54
  <div class="inside">
55
- <form name="updatecaptchaform" id="updatecaptchaform" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
56
  <?php wp_nonce_field( 'wpmem-update-captcha' ); ?>
57
  <table class="form-table">
58
  <?php // if reCAPTCHA is enabled...
52
 
53
  <h3><?php _e( 'Manage reCAPTCHA Options', 'wp-members' ); ?></h3>
54
  <div class="inside">
55
+ <form name="updatecaptchaform" id="updatecaptchaform" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
56
  <?php wp_nonce_field( 'wpmem-update-captcha' ); ?>
57
  <table class="form-table">
58
  <?php // if reCAPTCHA is enabled...
admin/tab-dialogs.php CHANGED
@@ -46,7 +46,7 @@ function wpmem_a_build_dialogs() {
46
  <h3><span>WP-Members <?php _e( 'Dialogs and Error Messages', 'wp-members' ); ?></span></h3>
47
  <div class="inside">
48
  <p><?php printf( __( 'You can customize the text for dialogs and error messages. Simple HTML is allowed %s etc.', 'wp-members' ), '- &lt;p&gt;, &lt;b&gt;, &lt;i&gt;,' ); ?></p>
49
- <form name="updatedialogform" id="updatedialogform" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
50
  <?php wp_nonce_field( 'wpmem-update-dialogs' ); ?>
51
  <table class="form-table">
52
  <?php if ( ! empty ( $wpmem->admin->dialogs ) ) {
46
  <h3><span>WP-Members <?php _e( 'Dialogs and Error Messages', 'wp-members' ); ?></span></h3>
47
  <div class="inside">
48
  <p><?php printf( __( 'You can customize the text for dialogs and error messages. Simple HTML is allowed %s etc.', 'wp-members' ), '- &lt;p&gt;, &lt;b&gt;, &lt;i&gt;,' ); ?></p>
49
+ <form name="updatedialogform" id="updatedialogform" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
50
  <?php wp_nonce_field( 'wpmem-update-dialogs' ); ?>
51
  <table class="form-table">
52
  <?php if ( ! empty ( $wpmem->admin->dialogs ) ) {
admin/tab-emails.php CHANGED
@@ -42,7 +42,7 @@ function wpmem_a_build_emails() {
42
  <?php _e( 'A list of shortcodes is available here.', 'wp-members' ); ?></a>
43
  </p>
44
  <hr />
45
- <form name="updateemailform" id="updateemailform" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
46
  <?php wp_nonce_field( 'wpmem-update-emails' ); ?>
47
  <table class="form-table">
48
  <tr valign="top">
42
  <?php _e( 'A list of shortcodes is available here.', 'wp-members' ); ?></a>
43
  </p>
44
  <hr />
45
+ <form name="updateemailform" id="updateemailform" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
46
  <?php wp_nonce_field( 'wpmem-update-emails' ); ?>
47
  <table class="form-table">
48
  <tr valign="top">
admin/tab-fields.php CHANGED
@@ -14,604 +14,837 @@
14
  * @copyright 2006-2017
15
  */
16
 
 
 
 
 
 
 
17
 
18
  /**
19
- * Builds the fields panel.
20
- *
21
- * @since 2.2.2
 
 
 
 
 
 
22
  *
23
- * @param string $wpmem_fields deprecated in 2.8.0
24
- * @global string $add_field_err_msg The fields error message
25
  */
26
- function wpmem_a_build_fields() {
27
-
28
- global $wpmem, $add_field_err_msg;
29
- $add_toggle = ( isset( $_GET['edit'] ) ) ? $_GET['edit'] : false;
30
- $wpmem_fields = wpmem_fields();
31
- ?>
32
- <div class="metabox-holder">
33
-
34
- <div id="post-body">
35
- <div id="post-body-content">
36
- <?php if ( $add_toggle && ( isset( $_POST['wpmem_admin_a'] ) != 'edit_field' ) ) {
37
- wpmem_a_field_edit( 'edit', $wpmem_fields, $add_toggle );
38
- } else {
39
- if ( ! $add_field_err_msg ) {
40
- wpmem_a_field_table( $wpmem_fields );
41
- }
42
- wpmem_a_field_edit( 'add' );
43
- } ?>
44
 
45
- <div class="postbox">
46
- <h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
47
- <div class="inside">
48
- <strong><i>See the <a href="http://rocketgeek.com/plugins/wp-members/users-guide/plugin-settings/fields/" target="_blank">Users Guide on the field manager</a>.</i></strong>
49
- </div>
50
- </div>
51
- </div><!-- #post-body-content -->
52
- </div><!-- #post-body -->
53
-
54
- </div><!-- .metabox-holder -->
55
- <?php
 
 
 
56
  }
57
 
 
 
 
 
 
 
 
 
58
 
59
  /**
60
- * reorders the fields on DnD
61
  *
62
- * @since 2.5.1
 
 
63
  */
64
- function wpmem_a_field_reorder() {
 
 
 
 
 
 
 
 
 
 
65
 
66
- // Start fresh.
67
- $new_order = $wpmem_old_fields = $wpmem_new_fields = $key = $row = '';
 
 
 
 
 
 
 
 
68
 
69
- $new_order = $_REQUEST['orderstring'];
70
- $new_order = explode( "&", $new_order );
 
 
71
 
72
- // Loop through $new_order to create new field array.
73
- $wpmem_old_fields = get_option( 'wpmembers_fields' );
74
- for ( $row = 0; $row < count( $new_order ); $row++ ) {
75
- if ( $row > 0 ) {
76
- $key = $new_order[ $row ];
77
- $key = substr( $key, 15 );
78
- if ( $key ) {
79
- for ( $x = 0; $x < count( $wpmem_old_fields ); $x++ ) {
80
- if ( $wpmem_old_fields[ $x ][2] == $key ) {
81
- $wpmem_new_fields[ $row - 1 ] = $wpmem_old_fields[ $x ];
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
  }
 
 
85
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
-
88
- update_option( 'wpmembers_fields', $wpmem_new_fields );
89
-
90
- die(); // This is required to return a proper result.
91
-
92
  }
93
 
94
-
95
  /**
96
- * Updates fields.
97
  *
98
  * @since 2.8
 
99
  *
100
- * @param string $action The field update action (update_fields|add|edit)
101
- * @global string $add_field_err_msg The add field error message
102
- * @return string $did_update The fields update message
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  *
104
- * @todo apply some additional form validation to the add/update process
105
  */
106
- function wpmem_update_fields( $action ) {
 
107
 
108
- // Get the current fields.
109
- $wpmem_fields = get_option( 'wpmembers_fields' );
110
  $wpmem_ut_fields = get_option( 'wpmembers_utfields' );
111
 
112
- if ( $action == 'update_fields' ) {
113
-
114
- // Check nonce.
115
- check_admin_referer( 'wpmem-update-fields' );
116
-
117
- // @todo - need some additional form validation here
118
 
119
- // Update user table fields.
120
- $arr = ( isset( $_POST['ut_fields'] ) ) ? $_POST['ut_fields'] : '';
121
- update_option( 'wpmembers_utfields', $arr );
122
-
123
- // Rebuild the array, don't touch user_email - it's always mandatory.
124
- $nrow = 0;
125
- foreach ( $wpmem_fields as $field ) {
126
 
127
- $meta_key = $field[2];
128
-
129
- // Check to see if the field is checked for deletion, and if not, add it to the new array.
130
- $delete_field = "del_" . $meta_key;
131
- $delete_field = ( isset( $_POST[ $delete_field ] ) ) ? $_POST[ $delete_field ] : false;
132
- if ( $delete_field != "delete" ) {
133
-
134
- for ( $i = 0; $i < 4; $i++ ) {
135
- $wpmem_newfields[ $nrow ][ $i ] = $field[ $i ];
136
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
- $wpmem_newfields[ $nrow ][0] = $nrow + 1;
139
 
140
- $display_field = $meta_key . "_display";
141
- $require_field = $meta_key . "_required";
142
- $checked_field = $meta_key . "_checked";
143
 
144
- if ( $field[2] != 'user_email' ){
145
- $wpmem_newfields[ $nrow ][4] = ( isset( $_POST[ $display_field ] ) ) ? 'y' : '';
146
- $wpmem_newfields[ $nrow ][5] = ( isset( $_POST[ $require_field ] ) ) ? 'y' : '';
147
- } else {
148
- $wpmem_newfields[ $nrow ][4] = 'y';
149
- $wpmem_newfields[ $nrow ][5] = 'y';
150
- }
151
-
152
- $wpmem_newfields[ $nrow ][6] = $field[6];
153
- $wpmem_newfields[ $nrow ][7] = ( isset( $field[7] ) ) ? $field[7] : '';
154
- if ( $field[3] == 'checkbox' ) {
155
- if ( isset( $_POST[ $checked_field ] ) && $_POST[ $checked_field ] == 'y' ) {
156
- $wpmem_newfields[ $nrow ][8] = 'y';
157
- } else {
158
- $wpmem_newfields[ $nrow ][8] = 'n';
159
- }
160
- }
161
 
162
- $nrow = $nrow + 1;
163
- }
 
 
 
 
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
-
167
- update_option( 'wpmembers_fields', $wpmem_newfields );
168
- $did_update = __( 'WP-Members fields were updated', 'wp-members' );
169
-
170
- } elseif ( $action == 'add_field' || 'edit_field' ) {
171
-
172
- // Check nonce.
173
- check_admin_referer( 'wpmem-add-fields' );
174
 
175
- global $add_field_err_msg;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
 
177
- $add_field_err_msg = false;
 
 
 
 
 
 
 
 
 
 
178
 
179
- // Error check that field label and option name are included and unique.
180
- $add_field_err_msg = ( $_POST['add_name'] == '' ) ? __( 'Field Label is required for adding a new field. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
181
- $add_field_err_msg = ( $_POST['add_option'] == '' ) ? __( 'Option Name is required for adding a new field. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
- $add_field_err_msg = ( !preg_match("/^[A-Za-z0-9_]*$/", $_POST['add_option'] ) ) ? __( 'Option Name must contain only letters, numbers, and underscores', 'wp-members' ) : $add_field_err_msg;
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
- // Check for duplicate field names.
186
- $chk_fields = array();
187
- foreach ( $wpmem_fields as $field ) {
188
- $chk_fields[] = $field[2];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  }
190
- $add_field_err_msg = ( in_array( $_POST['add_option'], $chk_fields ) ) ? __( 'A field with that option name already exists', 'wp-members' ) : $add_field_err_msg;
191
-
192
- // Error check for reserved terms.
193
- $reserved_terms = wpmem_wp_reserved_terms();
194
- $submitted_meta = $_POST['add_option'];
195
- if ( in_array( strtolower( $submitted_meta ), $reserved_terms ) ) {
196
- $add_field_err_msg = sprintf( __( 'Sorry, "%s" is a <a href="https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms" target="_blank">reserved term</a>. Field was not added.', 'wp-members' ), $submitted_term );
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  }
 
 
 
 
198
 
199
- // Error check option name for spaces and replace with underscores.
200
- $us_option = preg_replace( "/ /", '_', $submitted_meta );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
- $arr = array();
203
-
204
- $type = $_POST['add_type'];
205
-
206
- $arr[0] = ( $action == 'add_field' ) ? ( count( $wpmem_fields ) ) + 2 : false;
207
- $arr[1] = stripslashes( $_POST['add_name'] );
208
- $arr[2] = $us_option;
209
- $arr[3] = $type;
210
- $arr[4] = ( isset( $_POST['add_display'] ) ) ? $_POST['add_display'] : 'n';
211
- $arr[5] = ( isset( $_POST['add_required'] ) ) ? $_POST['add_required'] : 'n';
212
- $arr[6] = ( $us_option == 'user_nicename' || $us_option == 'display_name' || $us_option == 'nickname' ) ? 'y' : 'n';
213
-
214
- if ( $type == 'checkbox' ) {
215
- $add_field_err_msg = ( ! $_POST['add_checked_value'] ) ? __( 'Checked value is required for checkboxes. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
216
- $arr[7] = ( isset( $_POST['add_checked_value'] ) ) ? $_POST['add_checked_value'] : false;
217
- $arr[8] = ( isset( $_POST['add_checked_default'] ) ) ? $_POST['add_checked_default'] : 'n';
218
- }
219
 
220
- if ( $type == 'select'
221
- || $type == 'multiselect'
222
- || $type == 'radio'
223
- || $type == 'multicheckbox'
224
- ) {
225
- // Get the values.
226
- $str = stripslashes( $_POST['add_dropdown_value'] );
227
- // Remove linebreaks.
228
- $str = trim( str_replace( array("\r", "\r\n", "\n"), '', $str ) );
229
- // Create array.
230
- if ( ! function_exists( 'str_getcsv' ) ) {
231
- $arr[7] = explode( ',', $str );
232
- } else {
233
- $arr[7] = str_getcsv( $str, ',', '"' );
234
- }
235
- // If multiselect or multicheckbox, set delimiter.
236
- if ( 'multiselect' == $type || 'multicheckbox' == $type ) {
237
- $arr[8] = ( isset( $_POST['add_delimiter_value'] ) ) ? $_POST['add_delimiter_value'] : '|';
238
- }
239
- }
240
-
241
- if ( $type == 'file' || $type == 'image' ) {
242
- $arr[7] = stripslashes( $_POST['add_file_value'] );
243
- }
244
 
245
- if ( $_POST['add_type'] == 'hidden' ) {
246
- $add_field_err_msg = ( ! $_POST['add_hidden_value'] ) ? __( 'A value is required for hidden fields. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
247
- $arr[7] = ( isset( $_POST['add_hidden_value'] ) ) ? stripslashes( $_POST['add_hidden_value'] ) : '';
248
- }
249
 
250
- if ( $action == 'add_field' ) {
251
- if ( ! $add_field_err_msg ) {
252
- array_push( $wpmem_fields, $arr );
253
- update_option( 'wpmembers_fields', $wpmem_fields );
254
- $did_update = $_POST['add_name'] . ' ' . __( 'field was added', 'wp-members' );
255
- } else {
256
- $did_update = $add_field_err_msg;
257
- }
258
- } else {
259
 
260
- for ( $row = 0; $row < count( $wpmem_fields ); $row++ ) {
261
- if ( $wpmem_fields[ $row ][2] == $_GET['edit'] ) {
262
- $arr[0] = $wpmem_fields[ $row ][0];
263
- //$x = ( $arr[3] == 'checkbox' ) ? 8 : ( ( $arr[3] == 'select' || $arr[3] == 'file' ) ? 7 : 6 );
264
- for ( $r = 0; $r < count( $arr ); $r++ ) {
265
- $wpmem_fields[ $row ][ $r ] = $arr[ $r ];
266
- }
 
 
 
 
 
 
 
 
 
267
  }
268
  }
269
-
270
  update_option( 'wpmembers_fields', $wpmem_fields );
 
 
 
271
 
272
- $did_update = $_POST['add_name'] . ' ' . __( 'field was updated', 'wp-members' );
273
 
274
- }
275
- }
276
 
277
- if ( WPMEM_DEBUG == true && isset( $arr ) ) { echo "<pre>"; print_r($arr); echo "</pre>"; }
 
 
 
278
 
279
- global $wpmem;
280
- $wpmem->load_fields();
281
-
282
- return $did_update;
283
- }
284
 
 
285
 
286
- /**
287
- * Function to write the field edit link.
288
- *
289
- * @since 2.8
290
- *
291
- * @param string $field_id The option name of the field to be edited
292
- */
293
- function wpmem_fields_edit_link( $field_id ) {
294
- return '<a href="' . add_query_arg( array( 'page' => 'wpmem-settings', 'tab' => 'fields', 'edit' => $field_id ), get_admin_url() . 'options-general.php' ) . '">' . __( 'Edit' ) . '</a>';
295
- }
296
 
 
 
 
297
 
298
- /**
299
- * Function to dispay the add/edit field form.
300
- *
301
- * @since 2.8
302
- *
303
- * @param string $mode The mode for the function (edit|add)
304
- * @param array|null $wpmem_fields the array of fields
305
- * @param string|null $field the field being edited
306
- */
307
- function wpmem_a_field_edit( $mode, $wpmem_fields = null, $meta_key = null ) {
308
 
309
- global $wpmem;
 
 
 
 
 
310
 
311
- if ( $mode == 'edit' ) {
312
- $fields = wpmem_fields();
313
- $field = $fields[ $meta_key ];
314
- }
 
315
 
316
- $form_action = ( $mode == 'edit' ) ? 'editfieldform' : 'addfieldform';
 
317
 
318
- ?>
319
- <div class="postbox">
320
- <h3 class="title"><?php ( $mode == 'edit' ) ? _e( 'Edit Field', 'wp-members' ) : _e( 'Add a Field', 'wp-members' ); ?></h3>
321
- <div class="inside">
322
- <form name="<?php echo $form_action; ?>" id="<?php echo $form_action; ?>" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
323
- <?php wp_nonce_field( 'wpmem-add-fields' ); ?>
324
- <ul>
325
- <li>
326
- <label><?php _e( 'Field Label', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label>
327
- <input type="text" name="add_name" value="<?php echo ( $mode == 'edit' ) ? $field['label'] : false; ?>" />
328
- <?php _e( 'The name of the field as it will be displayed to the user.', 'wp-members' ); ?>
329
- </li>
330
- <li>
331
- <label><?php _e( 'Meta Key', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label>
332
- <?php if ( $mode == 'edit' ) {
333
- echo $meta_key; ?>
334
- <input type="hidden" name="add_option" value="<?php echo $meta_key; ?>" />
335
- <?php } else { ?>
336
- <input type="text" name="add_option" value="" />
337
- <?php _e( 'The database meta value for the field. It must be unique and contain no spaces (underscores are ok).', 'wp-members' ); ?>
338
- <?php } ?>
339
- </li>
340
- <li>
341
- <label><?php _e( 'Field Type', 'wp-members' ); ?></label>
342
- <?php if ( $mode == 'edit' ) {
343
- echo $field['type']; ?>
344
- <input type="hidden" name="add_type" value="<?php echo $field['type']; ?>" />
345
- <?php } else { ?>
346
- <select name="add_type" id="wpmem_field_type_select">
347
- <option value="text"><?php _e( 'text', 'wp-members' ); ?></option>
348
- <option value="email"><?php _e( 'email', 'wp-members' ); ?></option>
349
- <option value="textarea"><?php _e( 'textarea', 'wp-members' ); ?></option>
350
- <option value="checkbox"><?php _e( 'checkbox', 'wp-members' ); ?></option>
351
- <option value="multicheckbox"><?php _e( 'multiple checkbox', 'wp-members' ); ?></option>
352
- <option value="select"><?php _e( 'select (dropdown)', 'wp-members' ); ?></option>
353
- <option value="multiselect"><?php _e( 'multiple select', 'wp-members' ); ?></option>
354
- <option value="radio"><?php _e( 'radio group', 'wp-members' ); ?></option>
355
- <option value="password"><?php _e( 'password', 'wp-members' ); ?></option>
356
- <option value="image"><?php _e( 'image', 'wp-members' ); ?></option>
357
- <option value="file"><?php _e( 'file', 'wp-members' ); ?></option>
358
- <option value="url"><?php _e( 'url', 'wp-members' ); ?></option>
359
- <option value="hidden"><?php _e( 'hidden', 'wp-members' ); ?></option>
360
- </select>
361
- <?php } ?>
362
- </li>
363
- <li>
364
- <label><?php _e( 'Display?', 'wp-members' ); ?></label>
365
- <input type="checkbox" name="add_display" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['register'] ) : false; ?> />
366
- </li>
367
- <li>
368
- <label><?php _e( 'Required?', 'wp-members' ); ?></label>
369
- <input type="checkbox" name="add_required" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['required'] ) : false; ?> />
370
- </li>
371
- <?php if ( $mode == 'add' || ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ) { ?>
372
- <?php echo ( $mode == 'add' ) ? '<div id="wpmem_file_info">' : ''; ?>
373
- <li>
374
- <strong><?php _e( 'Additional information for field upload fields', 'wp-members' ); ?></strong>
375
- </li>
376
- <li>
377
- <label><?php _e( 'Accepted file types:', 'wp-members' ); ?></label>
378
- <input type="text" name="add_file_value" value="<?php echo ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ? $field['file_types'] : false; ?>" />
379
- </li>
380
- <li>
381
- <label>&nbsp;</label>
382
- <span class="description"><?php _e( 'Accepted file types should be set like this: jpg|jpeg|png|gif', 'wp-members' ); ?></span>
383
- </li>
384
- <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
385
- <?php } ?>
386
- <?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'checkbox' ) ) { ?>
387
- <?php echo ( $mode == 'add' ) ? '<div id="wpmem_checkbox_info">' : ''; ?>
388
- <li>
389
- <label><?php _e( 'Checked by default?', 'wp-members' ); ?></label>
390
- <input type="checkbox" name="add_checked_default" value="y" <?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? checked( true, $field['checked_default'] ) : false; ?> />
391
- </li>
392
- <li>
393
- <label><?php _e( 'Stored value if checked:', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label>
394
- <input type="text" name="add_checked_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? $field['checked_value'] : false; ?>" class="small-text" />
395
- </li>
396
- <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
397
- <?php }
398
-
399
- if ( isset( $field['type'] ) ) {
400
- $additional_settings = ( $field['type'] == 'select' || $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' || $field['type'] == 'radio' ) ? true : false;
401
- $delimiter_settings = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? true : false;
402
  }
403
- if ( $mode == 'add' || ( $mode == 'edit' && $additional_settings ) ) { ?>
404
- <?php echo ( $mode == 'add' ) ? '<div id="wpmem_dropdown_info">' : ''; ?>
405
- <?php if ( $mode == 'add' || ( $mode == 'edit' && $delimiter_settings ) ) {
406
- echo ( $mode == 'add' ) ? '<div id="wpmem_delimiter_info">' : '';
407
- if ( isset( $field['delimiter'] ) && ( "|" == $field['delimiter'] || "," == $field['delimiter'] ) ) {
408
- $delimiter = $field['delimiter'];
409
- } else {
410
- $delimiter = "|";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  }
412
- ?>
413
- <li>
414
- <label><?php _e( 'Stored values delimiter:', 'wp-members' ); ?></label>
415
- <select name = "add_delimiter_value">
416
- <option value="|" <?php selected( '|', $delimiter ); ?>>pipe "|"</option>
417
- <option value="," <?php selected( ',', $delimiter ); ?>>comma ","</option>
418
- </select>
419
- </li>
420
- <?php echo ( $mode == 'add' ) ? '</div>' : '';
421
- } ?>
422
- <li>
423
- <label style="vertical-align:top"><?php _e( 'Values (Displayed|Stored):', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label>
424
- <textarea name="add_dropdown_value" rows="5" cols="40"><?php
425
- // Accomodate editing the current dropdown values or create dropdown value example.
426
- if ( $mode == 'edit' ) {
427
- for ( $row = 0; $row < count( $field['values'] ); $row++ ) {
428
- // If the row contains commas (i.e. 1,000-10,000), wrap in double quotes.
429
- if ( strstr( $field['values'][ $row ], ',' ) ) {
430
- echo '"' . $field['values'][ $row ]; echo ( $row == count( $field['values'] )- 1 ) ? '"' : "\",\n";
431
- } else {
432
- echo $field['values'][ $row ]; echo ( $row == count( $field['values'] )- 1 ) ? "" : ",\n";
433
- } }
434
- } else {
435
- if (version_compare(PHP_VERSION, '5.3.0') >= 0) { ?>
436
- <---- Select One ---->|,
437
- Choice One|choice_one,
438
- "1,000|one_thousand",
439
- "1,000-10,000|1,000-10,000",
440
- Last Row|last_row<?php } else { ?>
441
- <---- Select One ---->|,
442
- Choice One|choice_one,
443
- Choice 2|choice_two,
444
- Last Row|last_row<?php } } ?></textarea>
445
- </li>
446
- <li>
447
- <label>&nbsp;</label>
448
- <span class="description"><?php _e( 'Options should be Option Name|option_value,', 'wp-members' ); ?></span>
449
- </li>
450
- <li>
451
- <label>&nbsp;</label>
452
- <span class="description"><a href="http://rocketgeek.com/plugins/wp-members/users-guide/registration/choosing-fields/" target="_blank"><?php _e( 'Visit plugin site for more information', 'wp-members' ); ?></a></span>
453
- </li>
454
- <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
455
- <?php } ?>
456
- <?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'hidden' ) ) { ?>
457
- <?php echo ( $mode == 'add' ) ? '<div id="wpmem_hidden_info">' : ''; ?>
458
- <li>
459
- <label><?php _e( 'Value', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label>
460
- <input type="text" name="add_hidden_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'hidden' ) ? $field['value'] : ''; ?>" />
461
- </li>
462
- <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
463
- <?php } ?>
464
- </ul><br />
465
- <?php if ( $mode == 'edit' ) { ?><input type="hidden" name="field_arr" value="<?php echo $meta_key; ?>" /><?php } ?>
466
- <input type="hidden" name="wpmem_admin_a" value="<?php echo ( $mode == 'edit' ) ? 'edit_field' : 'add_field'; ?>" />
467
- <?php $text = ( $mode == 'edit' ) ? __( 'Edit Field', 'wp-members' ) : __( 'Add Field', 'wp-members' ); ?>
468
- <?php submit_button( $text ); ?>
469
- </form>
470
- </div>
471
- </div>
472
- <?php
473
- }
474
 
 
475
 
 
 
 
 
 
 
476
 
477
  /**
478
- * Function to display the table of fields in the field manager tab.
479
- *
480
- * @since 2.8.0
481
  *
482
- * @global object $wpmem
483
- * @param array $wpmem_fields The array of fields.
484
  */
485
- function wpmem_a_field_table( $wpmem_fields ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
 
487
- global $wpmem; ?>
488
- <div class="postbox">
489
- <h3 class="title"><?php _e( 'Manage Fields', 'wp-members' ); ?></h3>
490
- <div class="inside">
491
- <p><?php _e( 'Determine which fields will display and which are required. This includes all fields, both native WP fields and WP-Members custom fields.', 'wp-members' ); ?>
492
- <br /><strong><?php _e( '(Note: Email is always mandatory and cannot be changed.)', 'wp-members' ); ?></strong></p>
493
- <form name="updatefieldform" id="updatefieldform" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
494
- <?php wp_nonce_field( 'wpmem-update-fields' ); ?>
495
- <table class="widefat" id="wpmem-fields">
496
- <thead><tr class="head">
497
- <th scope="col"><?php _e( 'Add/Delete', 'wp-members' ); ?></th>
498
- <th scope="col"><?php _e( 'Field Label', 'wp-members' ); ?></th>
499
- <th scope="col"><?php _e( 'Meta Key', 'wp-members' ); ?></th>
500
- <th scope="col"><?php _e( 'Field Type', 'wp-members' ); ?></th>
501
- <th scope="col"><?php _e( 'Display?', 'wp-members' ); ?></th>
502
- <th scope="col"><?php _e( 'Required?', 'wp-members' ); ?></th>
503
- <th scope="col"><?php _e( 'Checked?', 'wp-members' ); ?></th>
504
- <th scope="col"><?php _e( 'Edit' ); ?></th>
505
- <th scope="col"><?php _e( 'Users Screen', 'wp-members' ); ?></th>
506
- </tr></thead>
507
- <?php
508
- // Get the user table fields array.
509
- $wpmem_ut_fields = get_option( 'wpmembers_utfields' );
510
- // Order, label, optionname, input type, display, required, native.
511
- $class = '';
512
- // for ( $row = 0; $row < count($wpmem_fields); $row++ ) {
513
- $row = 0;
514
- foreach ( $wpmem_fields as $meta_key => $field ) {
515
- $class = ( $class == 'alternate' ) ? '' : 'alternate'; ?>
516
- <tr class="<?php echo $class; ?>" valign="top" id="<?php echo $meta_key;?>">
517
- <td width="10%"><?php
518
- $can_delete = ( $meta_key == 'user_nicename' || $meta_key == 'display_name' || $meta_key == 'nickname' ) ? true : false;
519
- if ( ( $can_delete ) || ! $field['native'] ) { ?><input type="checkbox" name="<?php echo "del_" . $meta_key; ?>" value="delete" /> <?php _e( 'Delete', 'wp-members' ); } ?></td>
520
- <td width="15%"><?php
521
- _e( $field['label'], 'wp-members' );
522
- echo ( $field['required'] ) ? '<span class="req">*</span>' : ''; ?>
523
- </td>
524
- <td width="15%"><?php echo $meta_key; ?></td>
525
- <td width="10%"><?php echo $field['type']; ?></td>
526
- <?php if ( $meta_key != 'user_email' ) { ?>
527
- <td width="10%"><?php echo wpmem_create_formfield( $meta_key . "_display", 'checkbox', true, $field['register'] ); ?></td>
528
- <td width="10%"><?php echo wpmem_create_formfield( $meta_key . "_required", 'checkbox', true, $field['required'] ); ?></td>
529
- <?php } else { ?>
530
- <td colspan="2" width="20%"><small><i><?php _e( '(Email cannot be removed)', 'wp-members' ); ?></i></small></td>
531
- <?php } ?>
532
- <td align="center" width="10%"><?php if ( $field['type'] == 'checkbox' ) {
533
- echo wpmem_create_formfield( $meta_key . "_checked", 'checkbox', true, $field['checked_default'] ); } ?>
534
- </td>
535
- <td width="10%"><?php echo ( $field['native'] ) ? 'native' : wpmem_fields_edit_link( $meta_key ); ?></td>
536
-
537
- <td align="center" width="10%">
538
- <?php
539
- $wpmem_ut_fields_skip = array( 'user_email', 'confirm_email', 'password', 'confirm_password' );
540
- if ( ! in_array( $meta_key, $wpmem_ut_fields_skip ) ) { ?>
541
- <input type="checkbox" name="ut_fields[<?php echo $meta_key; ?>]"
542
- value="<?php echo $field['label']; ?>"
543
- <?php echo ( ( $wpmem_ut_fields ) && ( in_array( $field['label'], $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> />
544
- <?php } ?>
545
- </td>
546
- </tr><?php
547
- } ?>
548
- <tr class="nodrag nodrop">
549
- <td>&nbsp;</td>
550
- <td><i><?php _e( 'Registration Date', 'wp-members' ); ?></i></td>
551
- <td><i>user_registered</i></td>
552
- <td colspan="4">&nbsp;</td>
553
- <td><?php _e( 'native', 'wp-members' ); ?></td>
554
- <td align="center">
555
- <input type="checkbox" name="ut_fields[user_registered]"
556
- value="Registration Date"
557
- <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Registration Date', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> />
558
- </td>
559
- </tr>
560
- <?php if ( $wpmem->mod_reg == 1 ) { ?>
561
- <tr class="nodrag nodrop">
562
- <td>&nbsp;</td>
563
- <td><i><?php _e( 'Active', 'wp-members' ); ?></i></td>
564
- <td><i>active</i></td>
565
- <td colspan="5">&nbsp;</td>
566
- <td align="center">
567
- <input type="checkbox" name="ut_fields[active]"
568
- value="Active"
569
- <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Active', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> />
570
- </td>
571
- </tr>
572
- <?php } ?>
573
- <tr class="nodrag nodrop">
574
- <td>&nbsp;</td>
575
- <td><i><?php _e( 'Registration IP', 'wp-members' ); ?></i></td>
576
- <td><i>wpmem_reg_ip</i></td>
577
- <td colspan="5">&nbsp;</td>
578
- <td align="center">
579
- <input type="checkbox" name="ut_fields[wpmem_reg_ip]"
580
- value="Registration IP"
581
- <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Registration IP', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> />
582
- </td>
583
- </tr>
584
- <?php if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) { ?>
585
- <tr class="nodrag nodrop">
586
- <td>&nbsp;</td>
587
- <td><i>Subscription Type</i></td>
588
- <td><i>exp_type</i></td>
589
- <td colspan="5">&nbsp;</td>
590
- <td align="center">
591
- <input type="checkbox" name="ut_fields[exp_type]"
592
- value="Subscription Type"
593
- <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Subscription Type', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> />
594
- </td>
595
- </tr>
596
- <tr class="nodrag nodrop">
597
- <td>&nbsp;</td>
598
- <td><i>Expires</i></td>
599
- <td><i>expires</i></td>
600
- <td colspan="5">&nbsp;</td>
601
- <td align="center">
602
- <input type="checkbox" name="ut_fields[expires]"
603
- value="Expires"
604
- <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Expires', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> />
605
- </td>
606
- </tr>
607
- <?php } ?>
608
- </table><br />
609
- <input type="hidden" name="wpmem_admin_a" value="update_fields" />
610
- <?php submit_button( __( 'Update Fields', 'wp-members' ) ); ?>
611
- </form>
612
- </div><!-- .inside -->
613
- </div>
614
- <?php
615
  }
616
 
617
  // End of file.
14
  * @copyright 2006-2017
15
  */
16
 
17
+ /**
18
+ * Load WP_Members_Fields_Table object
19
+ */
20
+ if( ! class_exists( 'WP_List_Table' ) ) {
21
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
22
+ }
23
 
24
  /**
25
+ * Filters and Actions.
26
+ */
27
+ add_action( 'wpmem_admin_do_tab', 'wpmem_a_fields_tab', 99, 1 );
28
+ add_action( 'wpmem_after_admin_init', 'wpmem_admin_fields_update' );
29
+ add_action( 'admin_print_styles', 'wpmem_a_fields_tab_scripts' );
30
+ add_action( 'wp_ajax_wpmem_a_field_reorder', 'wpmem_a_do_field_reorder' );
31
+
32
+ /**
33
+ * Calls the function to reorder fields.
34
  *
35
+ * @since 2.8.0
 
36
  */
37
+ function wpmem_a_do_field_reorder() {
38
+ // Reorder registration fields.
39
+ wpmem_a_field_reorder();
40
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
+ /**
43
+ * Creates the fields tab.
44
+ *
45
+ * @since 3.0.1
46
+ *
47
+ * @param string $tab The admin tab being displayed.
48
+ * @return string|bool The fields tab, otherwise false.
49
+ */
50
+ function wpmem_a_fields_tab( $tab ) {
51
+ if ( $tab == 'fields' ) {
52
+ // Render the fields tab.
53
+ wpmem_a_render_fields_tab();
54
+ return;
55
+ }
56
  }
57
 
58
+ /**
59
+ * Scripts needed for the fields tab.
60
+ *
61
+ * @since 3.1.8
62
+ */
63
+ function wpmem_a_fields_tab_scripts() {
64
+ wp_enqueue_script( 'jquery-ui-sortable' );
65
+ }
66
 
67
  /**
68
+ * Function to write the field edit link.
69
  *
70
+ * @since 2.8
71
+ *
72
+ * @param string $field_id The option name of the field to be edited
73
  */
74
+ function wpmem_fields_edit_link( $field_id ) {
75
+ $link_args = array(
76
+ 'page' => 'wpmem-settings',
77
+ 'tab' => 'fields',
78
+ 'mode' => 'edit',
79
+ 'edit' => 'field',
80
+ 'field' => $field_id,
81
+ );
82
+ $link = add_query_arg( $link_args, admin_url( 'options-general.php' ) );
83
+ return '<a href="' . $link . '">' . __( 'Edit' ) . '</a>';
84
+ }
85
 
86
+ /**
87
+ * Renders the content of the fields tab.
88
+ *
89
+ * @since 3.1.8
90
+ *
91
+ * @global object $wpmem The WP_Members Object.
92
+ * @global string $did_update
93
+ * @global string $delete_action
94
+ */
95
+ function wpmem_a_render_fields_tab() {
96
 
97
+ global $wpmem, $did_update, $delete_action;
98
+ $wpmem_fields = wpmem_fields();
99
+ $edit_meta = wpmem_get( 'field', false, 'get' );
100
+ $add_meta = wpmem_get( 'add_field', false );
101
 
102
+ if ( 'delete' == $delete_action ) {
103
+ $delete_fields = wpmem_get( 'delete' ); ?>
104
+
105
+ <p><?php _e( 'Are you sure you want to delete the following fields?', 'wp-members' ); ?></p>
106
+
107
+ <?php foreach ( $delete_fields as $meta ) {
108
+ echo $wpmem->fields[ $meta ]['label'] . ' (meta key: ' . $meta . ')<br />';
109
+ } ?>
110
+ <form name="<?php echo $delete_action; ?>" id="<?php echo $delete_action; ?>" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
111
+ <?php // wp_nonce_field( 'wpmem-delete-fields' ); ?>
112
+ <input type="hidden" name="delete_fields" value="<?php echo implode( ",", $delete_fields ); ?>" />
113
+ <input type="hidden" name="dodelete" value="delete_confirmed" />
114
+ <?php submit_button( 'Delete Fields' ); ?>
115
+ </form><?php
116
+
117
+ } else {
118
+
119
+ if ( 'delete_confirmed' == wpmem_get( 'dodelete' ) ) {
120
+ // validate wpmem-delete-fields nonce
121
+
122
+ $delete_fields = explode( ",", wpmem_get( 'delete_fields', array() ) );
123
+ $wpmem_new_fields = array();
124
+ foreach ( $wpmem_fields as $field ) {
125
+ if ( ! in_array( $field[2], $delete_fields ) ) {
126
+ $wpmem_new_fields[] = $field;
127
  }
128
  }
129
+ update_option( 'wpmembers_fields', $wpmem_new_fields );
130
+ $did_update = __( 'Fields deleted', 'wp-members' );
131
  }
132
+
133
+ if ( $did_update ) { ?>
134
+ <div id="message" class="updated fade"><p><strong><?php echo $did_update; ?></strong></p></div>
135
+ <?php }
136
+ if ( $edit_meta || $add_meta ) {
137
+ $mode = ( $edit_meta ) ? wpmem_get( 'mode', false, 'get' ) : 'add';
138
+ wpmem_a_render_fields_tab_field_edit( $mode, $wpmem_fields, $edit_meta );
139
+ } else {
140
+ wpmem_a_render_fields_tab_field_table();
141
+ } ?>
142
+ <h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
143
+ <div class="inside">
144
+ <strong><i><a href="http://rocketgeek.com/plugins/wp-members/docs/plugin-settings/fields/" target="_blank"><?php _e( 'Field Manager Documentation', 'wp-members' ); ?></a></i></strong>
145
+ </div>
146
+ <?php
147
  }
 
 
 
 
 
148
  }
149
 
 
150
  /**
151
+ * Function to dispay the add/edit field form.
152
  *
153
  * @since 2.8
154
+ * @since 3.1.8 Changed name from wpmem_a_field_edit().
155
  *
156
+ * @global object $wpmem The WP_Members Object.
157
+ * @param string $mode The mode for the function (edit|add)
158
+ * @param array|null $wpmem_fields The array of fields
159
+ * @param string|null $field The field being edited
160
+ */
161
+ function wpmem_a_render_fields_tab_field_edit( $mode, $wpmem_fields, $meta_key ) {
162
+ global $wpmem;
163
+ $fields = wpmem_fields();
164
+ if ( $mode == 'edit' ) {
165
+ $field = $fields[ $meta_key ];
166
+ }
167
+ $form_action = ( $mode == 'edit' ) ? 'editfieldform' : 'addfieldform';
168
+ $span_optional = '<span class="description">' . __( '(optional)', 'wp-members' ) . '</span>';
169
+ $span_required = '<span class="req">' . __( '(required)', 'wp-members' ) . '</span>';
170
+ $form_submit = array( 'mode' => $mode );
171
+ if ( isset( $_GET['field'] ) ) {
172
+ $form_submit['field'] = $meta_key;
173
+ } ?>
174
+ <h3 class="title"><?php ( $mode == 'edit' ) ? _e( 'Edit Field', 'wp-members' ) : _e( 'Add a Field', 'wp-members' ); ?></h3>
175
+ <form name="<?php echo $form_action; ?>" id="<?php echo $form_action; ?>" method="post" action="<?php echo wpmem_admin_form_post_url( $form_submit ); ?>">
176
+ <?php wp_nonce_field( 'wpmem-add-fields' ); ?>
177
+ <ul>
178
+ <li>
179
+ <label><?php _e( 'Field Label', 'wp-members' ); ?> <?php echo $span_required; ?></label>
180
+ <input type="text" name="add_name" value="<?php echo ( $mode == 'edit' ) ? $field['label'] : false; ?>" />
181
+ <?php _e( 'The name of the field as it will be displayed to the user.', 'wp-members' ); ?>
182
+ </li>
183
+ <li>
184
+ <label><?php _e( 'Meta Key', 'wp-members' ); ?> <?php echo $span_required; ?></label>
185
+ <?php if ( $mode == 'edit' ) {
186
+ echo "<span>$meta_key</span>"; ?>
187
+ <input type="hidden" name="add_option" value="<?php echo $meta_key; ?>" />
188
+ <?php } else { ?>
189
+ <input type="text" name="add_option" value="" />
190
+ <?php _e( 'The database meta value for the field. It must be unique and contain no spaces (underscores are ok).', 'wp-members' ); ?>
191
+ <?php } ?>
192
+ </li>
193
+ <li>
194
+ <label><?php _e( 'Field Type', 'wp-members' ); ?></label>
195
+ <?php if ( $mode == 'edit' ) {
196
+ echo '<span>' . $field['type'] . '</span>'; ?>
197
+ <input type="hidden" name="add_type" value="<?php echo $field['type']; ?>" />
198
+ <?php } else { ?>
199
+ <select name="add_type" id="wpmem_field_type_select">
200
+ <option value="text"><?php _e( 'text', 'wp-members' ); ?></option>
201
+ <option value="email"><?php _e( 'email', 'wp-members' ); ?></option>
202
+ <option value="textarea"><?php _e( 'textarea', 'wp-members' ); ?></option>
203
+ <option value="checkbox"><?php _e( 'checkbox', 'wp-members' ); ?></option>
204
+ <option value="multicheckbox"><?php _e( 'multiple checkbox', 'wp-members' ); ?></option>
205
+ <option value="select"><?php _e( 'select (dropdown)', 'wp-members' ); ?></option>
206
+ <option value="multiselect"><?php _e( 'multiple select', 'wp-members' ); ?></option>
207
+ <option value="radio"><?php _e( 'radio group', 'wp-members' ); ?></option>
208
+ <option value="password"><?php _e( 'password', 'wp-members' ); ?></option>
209
+ <option value="image"><?php _e( 'image', 'wp-members' ); ?></option>
210
+ <option value="file"><?php _e( 'file', 'wp-members' ); ?></option>
211
+ <option value="url"><?php _e( 'url', 'wp-members' ); ?></option>
212
+ <option value="number"><?php _e( 'number', 'wp-members' ); ?></option>
213
+ <option value="date"><?php _e( 'date', 'wp-members' ); ?></option>
214
+ <option value="hidden"><?php _e( 'hidden', 'wp-members' ); ?></option>
215
+ </select>
216
+ <?php } ?>
217
+ </li>
218
+ <li>
219
+ <label><?php _e( 'Display?', 'wp-members' ); ?></label>
220
+ <input type="checkbox" name="add_display" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['register'] ) : false; ?> />
221
+ </li>
222
+ <li>
223
+ <label><?php _e( 'Required?', 'wp-members' ); ?></label>
224
+ <input type="checkbox" name="add_required" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['required'] ) : false; ?> />
225
+ </li>
226
+ <!--<div id="wpmem_allowhtml">
227
+ <li>
228
+ <label><?php _e( 'Allow HTML?', 'wp-members' ); ?></label>
229
+ <input type="checkbox" name="add_html" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['html'] ) : false; ?> />
230
+ </li>
231
+ </div>-->
232
+ <?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'text', 'password', 'email', 'url', 'number', 'date', 'textarea' ) ) ) ) ) { ?>
233
+ <?php echo ( $mode == 'add' ) ? '<div id="wpmem_placeholder">' : ''; ?>
234
+ <li>
235
+ <label><?php _e( 'Placeholder', 'wp-members' ); ?></label>
236
+ <input type="text" name="add_placeholder" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['placeholder'] ) ? $field['placeholder'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
237
+ </li>
238
+ <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
239
+ <?php } ?>
240
+ <?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'text', 'password', 'email', 'url', 'number', 'date' ) ) ) ) ) { ?>
241
+ <?php echo ( $mode == 'add' ) ? '<div id="wpmem_pattern">' : ''; ?>
242
+ <li>
243
+ <label><?php _e( 'Pattern', 'wp-members' ); ?></label>
244
+ <input type="text" name="add_pattern" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['pattern'] ) ? $field['pattern'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
245
+ </li>
246
+ <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
247
+ <?php echo ( $mode == 'add' ) ? '<div id="wpmem_title">' : ''; ?>
248
+ <li>
249
+ <label><?php _e( 'Title', 'wp-members' ); ?></label>
250
+ <input type="text" name="add_title" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['title'] ) ? $field['title'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
251
+ </li>
252
+ <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
253
+ <?php } ?>
254
+
255
+ <?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'number', 'date' ) ) ) ) ) { ?>
256
+ <?php echo ( $mode == 'add' ) ? '<div id="wpmem_min_max">' : ''; ?>
257
+ <li>
258
+ <label><?php _e( 'Minimum Value', 'wp-members' ); ?></label>
259
+ <input type="text" name="add_min" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['min'] ) ? $field['min'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
260
+ </li>
261
+ <li>
262
+ <label><?php _e( 'Maximum Value', 'wp-members' ); ?></label>
263
+ <input type="text" name="add_max" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['max'] ) ? $field['max'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
264
+ </li>
265
+ <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
266
+ <?php } ?>
267
+ <?php if ( $mode == 'add' || ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ) { ?>
268
+ <?php echo ( $mode == 'add' ) ? '<div id="wpmem_file_info">' : ''; ?>
269
+ <li>
270
+ <label><?php _e( 'Accepted file types:', 'wp-members' ); ?></label>
271
+ <input type="text" name="add_file_value" value="<?php echo ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ? $field['file_types'] : false; ?>" />
272
+ </li>
273
+ <li>
274
+ <label>&nbsp;</label>
275
+ <span class="description"><?php _e( 'Accepted file types should be set like this: jpg|jpeg|png|gif', 'wp-members' ); ?></span>
276
+ </li>
277
+ <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
278
+ <?php } ?>
279
+ <?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'checkbox' ) ) { ?>
280
+ <?php echo ( $mode == 'add' ) ? '<div id="wpmem_checkbox_info">' : ''; ?>
281
+ <li>
282
+ <label><?php _e( 'Checked by default?', 'wp-members' ); ?></label>
283
+ <input type="checkbox" name="add_checked_default" value="y" <?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? checked( true, $field['checked_default'] ) : false; ?> />
284
+ </li>
285
+ <li>
286
+ <label><?php _e( 'Stored value if checked:', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label>
287
+ <input type="text" name="add_checked_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? $field['checked_value'] : false; ?>" class="small-text" />
288
+ </li>
289
+ <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
290
+ <?php }
291
+
292
+ if ( isset( $field['type'] ) ) {
293
+ $additional_settings = ( $field['type'] == 'select' || $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' || $field['type'] == 'radio' ) ? true : false;
294
+ $delimiter_settings = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? true : false;
295
+ }
296
+ if ( $mode == 'add' || ( $mode == 'edit' && $additional_settings ) ) { ?>
297
+ <?php echo ( $mode == 'add' ) ? '<div id="wpmem_dropdown_info">' : ''; ?>
298
+ <?php if ( $mode == 'add' || ( $mode == 'edit' && $delimiter_settings ) ) {
299
+ echo ( $mode == 'add' ) ? '<div id="wpmem_delimiter_info">' : '';
300
+ if ( isset( $field['delimiter'] ) && ( "|" == $field['delimiter'] || "," == $field['delimiter'] ) ) {
301
+ $delimiter = $field['delimiter'];
302
+ } else {
303
+ $delimiter = "|";
304
+ }
305
+ ?>
306
+ <li>
307
+ <label><?php _e( 'Stored values delimiter:', 'wp-members' ); ?></label>
308
+ <select name = "add_delimiter_value">
309
+ <option value="|" <?php selected( '|', $delimiter ); ?>>pipe "|"</option>
310
+ <option value="," <?php selected( ',', $delimiter ); ?>>comma ","</option>
311
+ </select>
312
+ </li>
313
+ <?php echo ( $mode == 'add' ) ? '</div>' : '';
314
+ } ?>
315
+ <li>
316
+ <label style="vertical-align:top"><?php _e( 'Values (Displayed|Stored):', 'wp-members' ); ?> <?php echo $span_required; ?></label>
317
+ <textarea name="add_dropdown_value" rows="5" cols="40"><?php
318
+ // Accomodate editing the current dropdown values or create dropdown value example.
319
+ if ( $mode == 'edit' ) {
320
+ for ( $row = 0; $row < count( $field['values'] ); $row++ ) {
321
+ // If the row contains commas (i.e. 1,000-10,000), wrap in double quotes.
322
+ if ( strstr( $field['values'][ $row ], ',' ) ) {
323
+ echo '"' . $field['values'][ $row ]; echo ( $row == count( $field['values'] )- 1 ) ? '"' : "\",\n";
324
+ } else {
325
+ echo $field['values'][ $row ]; echo ( $row == count( $field['values'] )- 1 ) ? "" : ",\n";
326
+ } }
327
+ } else {
328
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0) { ?>
329
+ <---- Select One ---->|,
330
+ Choice One|choice_one,
331
+ "1,000|one_thousand",
332
+ "1,000-10,000|1,000-10,000",
333
+ Last Row|last_row<?php } else { ?>
334
+ <---- Select One ---->|,
335
+ Choice One|choice_one,
336
+ Choice 2|choice_two,
337
+ Last Row|last_row<?php } } ?></textarea>
338
+ </li>
339
+ <li>
340
+ <label>&nbsp;</label>
341
+ <span class="description"><?php _e( 'Options should be Option Name|option_value,', 'wp-members' ); ?></span>
342
+ </li>
343
+ <li>
344
+ <label>&nbsp;</label>
345
+ <span class="description"><a href="http://rocketgeek.com/plugins/wp-members/users-guide/registration/choosing-fields/" target="_blank"><?php _e( 'Visit plugin site for more information', 'wp-members' ); ?></a></span>
346
+ </li>
347
+ <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
348
+ <?php } ?>
349
+ <?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'hidden' ) ) { ?>
350
+ <?php echo ( $mode == 'add' ) ? '<div id="wpmem_hidden_info">' : ''; ?>
351
+ <li>
352
+ <label><?php _e( 'Value', 'wp-members' ); ?> <?php echo $span_required; ?></label>
353
+ <input type="text" name="add_hidden_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'hidden' ) ? $field['value'] : ''; ?>" />
354
+ </li>
355
+ <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
356
+ <?php } ?>
357
+ </ul><br />
358
+ <?php if ( $mode == 'edit' ) { ?><input type="hidden" name="field_arr" value="<?php echo $meta_key; ?>" /><?php } ?>
359
+ <?php if ( 'add' == $mode ) {
360
+ $ids = array();
361
+ foreach ( $fields as $f ) {
362
+ $ids[] = $f[0];
363
+ }
364
+ sort( $ids );
365
+ $field_order_id = end( $ids ) + 1;
366
+ } else {
367
+ $field_order_id = $field[0];
368
+ } ?>
369
+ <input type="hidden" name="add_order_id" value="<?php echo $field_order_id; ?>" />
370
+ <input type="hidden" name="wpmem_admin_a" value="<?php echo ( $mode == 'edit' ) ? 'edit_field' : 'add_field'; ?>" />
371
+ <?php $text = ( $mode == 'edit' ) ? __( 'Edit Field', 'wp-members' ) : __( 'Add Field', 'wp-members' ); ?>
372
+ <?php submit_button( $text ); ?>
373
+ <p><a href="<?php echo add_query_arg( array( 'page' => 'wpmem-settings', 'tab' => 'fields' ), get_admin_url() . 'options-general.php' ); ?>">&laquo; <?php _e( 'Return to Fields Table', 'wp-members' ); ?></a></p>
374
+ </form><?php
375
+ }
376
+
377
+ /**
378
+ * Function to display the table of fields in the field manager tab.
379
+ *
380
+ * @since 2.8.0
381
+ * @since 3.1.8 Changed name from wpmem_a_field_table().
382
  *
383
+ * @global object $wpmem
384
  */
385
+ function wpmem_a_render_fields_tab_field_table() {
386
+ global $wpmem;
387
 
388
+ $wpmem_ut_fields_skip = array( 'user_email', 'confirm_email', 'password', 'confirm_password' );
 
389
  $wpmem_ut_fields = get_option( 'wpmembers_utfields' );
390
 
391
+ $wpmem_fields = get_option( 'wpmembers_fields', array() );
392
+ foreach ( $wpmem_fields as $key => $field ) {
 
 
 
 
393
 
394
+ // @todo - transitional until new array keys
395
+ if ( is_numeric( $key ) ) {
 
 
 
 
 
396
 
397
+ $meta = $field[2];
398
+
399
+ $ut_checked = ( ( $wpmem_ut_fields ) && ( in_array( $field[1], $wpmem_ut_fields ) ) ) ? $field[1] : '';
400
+ $field_items[] = array(
401
+ 'order' => $field[0],
402
+ 'label' => $field[1],
403
+ 'meta' => $meta,
404
+ 'type' => $field[3],
405
+ 'display' => ( $meta != 'user_email' ) ? wpmem_create_formfield( $meta . "_display", 'checkbox', 'y', $field[4] ) : '',
406
+ 'req' => ( $meta != 'user_email' ) ? wpmem_create_formfield( $meta . "_required", 'checkbox', 'y', $field[5] ) : '',
407
+ //'profile' => ( $meta != 'user_email' ) ? wpmem_create_formfield( $meta . "_profile", 'checkbox', true, $field[6] ) : '',
408
+ 'edit' => wpmem_fields_edit_link( $meta ),
409
+ 'userscrn' => ( ! in_array( $meta, $wpmem_ut_fields_skip ) ) ? wpmem_create_formfield( 'ut_fields[' . $meta . ']', 'checkbox', $field[1], $ut_checked ) : '',
410
+ 'sort' => '<span class="ui-icon ui-icon-grip-dotted-horizontal" title="' . __( 'Drag and drop to reorder fields', 'wp-members' ) . '"></span>',
411
+ );
412
+ }
413
+ }
414
+
415
+ $extra_user_screen_items = array(
416
+ 'user_registered' => 'Registration Date',
417
+ 'active' => 'Active',
418
+ 'wpmem_reg_ip' => 'Registration IP',
419
+ 'exp_type' => 'Subscription Type',
420
+ 'expires' => 'Expires',
421
+ );
422
+
423
+ foreach ( $extra_user_screen_items as $key => $item ) {
424
+ $ut_checked = ( ( $wpmem_ut_fields ) && ( in_array( $item, $wpmem_ut_fields ) ) ) ? $item : '';
425
+ if ( 'user_registered' == $key || ( 'active' == $key && 1 == $wpmem->mod_reg ) || 'wpmem_reg_ip' == $key || defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 && ( 'exp_type' == $key || 'expires' == $key ) ) {
426
+ $user_screen_items[ $key ] = array( 'label' => __( $item, 'wp-members' ), 'meta' => $key,
427
+ 'userscrn' => wpmem_create_formfield( "ut_fields[{$key}]", 'checkbox', $item, $ut_checked ),
428
+ );
429
+ }
430
+ }
431
+
432
+ foreach ( $user_screen_items as $screen_item ) {
433
+ $field_items[] = array(
434
+ 'label' => $screen_item['label'],
435
+ 'meta' => $screen_item['meta'],
436
+ 'type' => '',
437
+ 'display' => '',
438
+ 'req' => '',
439
+ 'profile' => '',
440
+ 'edit' => '',
441
+ 'userscrn' => $screen_item['userscrn'],
442
+ 'sort' => '',
443
+ );
444
+ }
445
 
446
+ $table = new WP_Members_Fields_Table();
447
 
448
+ $heading = __( 'Manage Fields', 'wp-members' );
449
+ //$description = __( 'Displaying fields for:', 'wp-members' );
450
+ //$which_form = $wpmem->form_tags[ $wpmem->admin->current_form ];
451
 
452
+ echo '<div class="wrap">';
453
+ printf( '<h3 class="title">%s</h3>', $heading );
454
+ //printf( '<p>%s <strong>%s</strong></p>', $description, $which_form );
455
+ printf( '<form name="updatefieldform" id="updatefieldform" method="post" action="%s">', wpmem_admin_form_post_url() );
 
 
 
 
 
 
 
 
 
 
 
 
 
456
 
457
+ $table->items = $field_items;
458
+ $table->prepare_items();
459
+ $table->display();
460
+ echo '</form>';
461
+ echo '</div>';
462
+ }
463
 
464
+ /**
465
+ * Extends the WP_List_Table to create a table of form fields.
466
+ *
467
+ * @since 3.1.8
468
+ */
469
+ class WP_Members_Fields_Table extends WP_List_Table {
470
+
471
+ private $excludes = array( 'user_registered', 'active', 'wpmem_reg_ip', 'exp_type', 'expires' );
472
+
473
+ private $no_delete = array( 'user_email', 'first_name', 'last_name', 'user_url' );
474
+
475
+ /**
476
+ * Checkbox at start of row.
477
+ *
478
+ * @since 3.1.8
479
+ *
480
+ * @param $item
481
+ * @return string The checkbox.
482
+ */
483
+ function column_cb( $item ) {
484
+ if ( in_array( $item['meta'], $this->no_delete ) || in_array( $item['meta'], $this->excludes ) ) {
485
+ return;
486
+ } else {
487
+ return sprintf( '<input type="checkbox" name="delete[]" value="%s" title="%s" />', $item['meta'], __( 'delete', 'wp-members' ) );
488
  }
489
+ }
 
 
 
 
 
 
 
490
 
491
+ /**
492
+ * Returns table columns.
493
+ *
494
+ * @since 3.1.8
495
+ *
496
+ * @return array
497
+ */
498
+ function get_columns() {
499
+ return array(
500
+ 'cb' => '<input type="checkbox" />',
501
+ 'label' => __( 'Display Label', 'wp-members' ),
502
+ 'meta' => __( 'Meta Key', 'wp-members' ),
503
+ 'type' => __( 'Field Type', 'wp-members' ),
504
+ 'display' => __( 'Display?', 'wp-members' ),
505
+ 'req' => __( 'Required?', 'wp-members' ),
506
+ //'profile' => __( 'Profile Only', 'wp-members' ),
507
+ 'edit' => __( 'Edit', 'wp-members' ),
508
+ 'userscrn' => __( 'Users Screen', 'wp-members' ),
509
+ 'sort' => '',
510
+ );
511
+ }
512
 
513
+ /**
514
+ * Set up table columns.
515
+ *
516
+ * @since 3.1.8
517
+ */
518
+ function prepare_items() {
519
+ $columns = $this->get_columns();
520
+ $hidden = array();
521
+ $sortable = array();
522
+ $this->_column_headers = array( $columns, $hidden, $sortable );
523
+ }
524
 
525
+ /**
526
+ * Iterates through the columns
527
+ *
528
+ * @since 3.1.8
529
+ *
530
+ * @param array $item
531
+ * @param string $column_name
532
+ * @return string $item[ $column_name ]
533
+ */
534
+ function column_default( $item, $column_name ) {
535
+ switch( $column_name ) {
536
+ default:
537
+ return $item[ $column_name ];
538
+ }
539
+ }
540
 
541
+ /**
542
+ * Sets actions in the bulk menu.
543
+ *
544
+ * @since 3.1.8
545
+ *
546
+ * @return array $actions
547
+ */
548
+ function get_bulk_actions() {
549
+ $actions = array(
550
+ 'delete' => __( 'Delete Selected', 'wp-members' ),
551
+ 'save' => __( 'Save Settings', 'wp-members' ),
552
+ );
553
+ return $actions;
554
+ }
555
 
556
+ /**
557
+ * Handles "delete" column - checkbox
558
+ *
559
+ * @since 3.1.8
560
+ *
561
+ * @param array $item
562
+ * @return string
563
+ */
564
+ function column_delete( $item ) {
565
+ $can_delete = ( $item['meta_key'] == 'user_nicename' || $item['meta_key'] == 'display_name' || $item['meta_key'] == 'nickname' ) ? true : false;
566
+ return ( ( $can_delete ) || $item['native'] != true ) ? sprintf( '<input type="checkbox" name="field[%s]" value="delete" />', $item['meta'] ) : '';
567
+ }
568
+
569
+ /**
570
+ * Sets rows so that they have field IDs in the id.
571
+ *
572
+ * @since 3.1.8
573
+ *
574
+ * @global wpmem
575
+ * @param array $columns
576
+ */
577
+ function single_row( $columns ) {
578
+ if ( in_array( $columns['meta'], $this->excludes ) ) {
579
+ echo '<tr id="' . $columns['meta'] . '" class="nodrag nodrop">';
580
+ echo $this->single_row_columns( $columns );
581
+ echo "</tr>\n";
582
+ } else {
583
+ echo '<tr id="list_items_' . $columns['order'] . '" class="list_item" list_item="' . $columns['order'] . '">';
584
+ echo $this->single_row_columns( $columns );
585
+ echo "</tr>\n";
586
  }
587
+ }
588
+
589
+ public function process_bulk_action() {
590
+
591
+ //nonce validations,etc
592
+
593
+ $action = $this->current_action();
594
+
595
+ switch ( $action ) {
596
+
597
+ case 'delete':
598
+
599
+ // Do whatever you want
600
+ wp_redirect( esc_url( add_query_arg() ) );
601
+ break;
602
+
603
+ default:
604
+ // do nothing or something else
605
+ return;
606
+ break;
607
  }
608
+ return;
609
+ }
610
+
611
+ }
612
 
613
+ /**
614
+ * Javascript to ID the fields table and add curser style to rows.
615
+ *
616
+ * @since 3.1.8
617
+ */
618
+ add_action( 'admin_footer', 'wpmem_bulk_fields_action' );
619
+ function wpmem_bulk_fields_action() {
620
+ // if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'fields' ) {
621
+ if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'fields' ) {
622
+ ?><script type="text/javascript">
623
+ (function($) {
624
+ $(document).ready(function() {
625
+ $("table").attr("id", "wpmem-fields");
626
+ /**$("tr").attr('style', 'cursor:move;');**/
627
+ });
628
+ })(jQuery);
629
+ jQuery('<input id="add_field" name="add_field" class="button action" type="submit" value="<?php _e( 'Add Field', 'wp-members' ); ?>" />').appendTo(".top .bulkactions");
630
+ jQuery('<input id="add_field" name="add_field" class="button action" type="submit" value="<?php _e( 'Add Field', 'wp-members' ); ?>" />').appendTo(".bottom .bulkactions");
631
+ </script><?php
632
+ }
633
+ }
634
 
635
+ /**
636
+ * Updates fields.
637
+ *
638
+ * Derived from wpmem_update_fields()
639
+ *
640
+ * @since 3.1.8
641
+ *
642
+ * @global object $wpmem
643
+ * @global string $did_update
644
+ * @global string $add_field_err_msg The add field error message
645
+ */
646
+ function wpmem_admin_fields_update() {
647
+
648
+ global $wpmem, $did_update, $delete_action;
 
 
 
649
 
650
+ if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'fields' ) {
651
+ // Get the current fields.
652
+ $wpmem_fields = get_option( 'wpmembers_fields' );
653
+
654
+ $action = wpmem_get( 'action', false );
655
+ $action = ( -1 == $action ) ? wpmem_get( 'action2' ) : $action;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656
 
657
+ $delete_action = false;
 
 
 
658
 
659
+ if ( 'save' == $action ) {
 
 
 
 
 
 
 
 
660
 
661
+ // Check nonce.
662
+ //check_admin_referer( 'wpmem-update-fields' );
663
+
664
+ // Update user table fields.
665
+ $arr = ( isset( $_POST['ut_fields'] ) ) ? $_POST['ut_fields'] : '';
666
+ update_option( 'wpmembers_utfields', $arr );
667
+
668
+ // Update display/required settings
669
+ foreach ( $wpmem_fields as $key => $field ) {
670
+ $meta_key = $field[2];
671
+ if ( 'user_email' == $meta_key ) {
672
+ $wpmem_fields[ $key ][4] = 'y';
673
+ $wpmem_fields[ $key ][5] = 'y';
674
+ } else {
675
+ $wpmem_fields[ $key ][4] = ( wpmem_get( $meta_key . "_display" ) ) ? 'y' : '';
676
+ $wpmem_fields[ $key ][5] = ( wpmem_get( $meta_key . "_required" ) ) ? 'y' : '';
677
  }
678
  }
 
679
  update_option( 'wpmembers_fields', $wpmem_fields );
680
+ $wpmem->load_fields();
681
+ $did_update = __( 'WP-Members fields were updated', 'wp-members' );
682
+ return $did_update;
683
 
684
+ } elseif ( 'delete' == $action ) {
685
 
686
+ $delete_action = 'delete';
 
687
 
688
+ } elseif ( 'add_field' == wpmem_get( 'wpmem_admin_a' ) || 'edit_field' == wpmem_get( 'wpmem_admin_a' ) ) {
689
+
690
+ // Set action.
691
+ $action = wpmem_get( 'wpmem_admin_a' );
692
 
693
+ // Check nonce.
694
+ //check_admin_referer( 'wpmem-add-fields' );
 
 
 
695
 
696
+ global $add_field_err_msg;
697
 
698
+ $add_field_err_msg = false;
699
+ $add_name = wpmem_get( 'add_name' );
700
+ $add_option = wpmem_get( 'add_option' );
 
 
 
 
 
 
 
701
 
702
+ // Error check that field label and option name are included and unique.
703
+ $add_field_err_msg = ( ! $add_name ) ? __( 'Field Label is required. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
704
+ $add_field_err_msg = ( ! $add_option ) ? __( 'Meta Key is required. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
705
 
706
+ $add_field_err_msg = ( ! preg_match("/^[A-Za-z0-9_]*$/", $add_option ) ) ? __( 'Meta Key must contain only letters, numbers, and underscores', 'wp-members' ) : $add_field_err_msg;
 
 
 
 
 
 
 
 
 
707
 
708
+ // Check for duplicate field names.
709
+ $chk_fields = array();
710
+ foreach ( $wpmem_fields as $field ) {
711
+ $chk_fields[] = $field[2];
712
+ }
713
+ $add_field_err_msg = ( in_array( $add_option, $chk_fields ) ) ? __( 'A field with that meta key already exists', 'wp-members' ) : $add_field_err_msg;
714
 
715
+ // Error check for reserved terms.
716
+ $reserved_terms = wpmem_wp_reserved_terms();
717
+ if ( in_array( strtolower( $add_option ), $reserved_terms ) ) {
718
+ $add_field_err_msg = sprintf( __( 'Sorry, "%s" is a <a href="https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms" target="_blank">reserved term</a>. Field was not added.', 'wp-members' ), $submitted_term );
719
+ }
720
 
721
+ // Error check option name for spaces and replace with underscores.
722
+ $us_option = preg_replace( "/ /", '_', $add_option );
723
 
724
+ $arr = array();
725
+
726
+ $type = wpmem_get( 'add_type' );
727
+
728
+ $arr[0] = wpmem_get( 'add_order_id' );
729
+ $arr[1] = stripslashes( wpmem_get( 'add_name' ) );
730
+ $arr[2] = $us_option;
731
+ $arr[3] = $type;
732
+ $arr[4] = wpmem_get( 'add_display', 'n' );
733
+ $arr[5] = wpmem_get( 'add_required', 'n' );
734
+ $arr[6] = ( $us_option == 'user_nicename' || $us_option == 'display_name' || $us_option == 'nickname' ) ? 'y' : 'n';
735
+
736
+ if ( 'text' == $type || 'email' == $type || 'textarea' == $type || 'password' == $type || 'url' == $type || 'number' == $type || 'date' == $type ) {
737
+ $arr['placeholder'] = wpmem_get( 'add_placeholder' );
738
+ }
739
+
740
+ if ( 'text' == $type || 'email' == $type || 'password' == $type || 'url' == $type || 'number' == $type || 'date' == $type ) {
741
+ $arr['pattern'] = wpmem_get( 'add_pattern' );
742
+ $arr['title'] = wpmem_get( 'add_title' );
743
+ }
744
+
745
+ if ( 'number' == $type || 'date' == $type ) {
746
+ $arr['min'] = wpmem_get( 'add_min' );
747
+ $arr['max'] = wpmem_get( 'add_max' );
748
+ }
749
+
750
+ if ( $type == 'checkbox' ) {
751
+ $add_field_err_msg = ( ! $_POST['add_checked_value'] ) ? __( 'Checked value is required for checkboxes. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
752
+ $arr[7] = wpmem_get( 'add_checked_value', false );
753
+ $arr[8] = wpmem_get( 'add_checked_default', 'n' );
754
+ }
755
+
756
+ if ( $type == 'select'
757
+ || $type == 'multiselect'
758
+ || $type == 'radio'
759
+ || $type == 'multicheckbox'
760
+ ) {
761
+ // Get the values.
762
+ $str = stripslashes( $_POST['add_dropdown_value'] );
763
+ // Remove linebreaks.
764
+ $str = trim( str_replace( array("\r", "\r\n", "\n"), '', $str ) );
765
+ // Create array.
766
+ if ( ! function_exists( 'str_getcsv' ) ) {
767
+ $arr[7] = explode( ',', $str );
768
+ } else {
769
+ $arr[7] = str_getcsv( $str, ',', '"' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770
  }
771
+ // If multiselect or multicheckbox, set delimiter.
772
+ if ( 'multiselect' == $type || 'multicheckbox' == $type ) {
773
+ $arr[8] = ( isset( $_POST['add_delimiter_value'] ) ) ? $_POST['add_delimiter_value'] : '|';
774
+ }
775
+ }
776
+
777
+ if ( $type == 'file' || $type == 'image' ) {
778
+ $arr[7] = stripslashes( $_POST['add_file_value'] );
779
+ }
780
+
781
+ if ( wpmem_get( 'add_type' ) == 'hidden' ) {
782
+ $add_field_err_msg = ( ! $_POST['add_hidden_value'] ) ? __( 'A value is required for hidden fields. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
783
+ $arr[7] = ( isset( $_POST['add_hidden_value'] ) ) ? stripslashes( $_POST['add_hidden_value'] ) : '';
784
+ }
785
+
786
+ if ( $action == 'add_field' ) {
787
+ if ( ! $add_field_err_msg ) {
788
+ array_push( $wpmem_fields, $arr );
789
+ $did_update = sprintf( __( '%s was added', 'wp-members' ), $_POST['add_name'] );
790
+ } else {
791
+ $did_update = $add_field_err_msg;
792
+ }
793
+ } else {
794
+ for ( $row = 0; $row < count( $wpmem_fields ); $row++ ) {
795
+ if ( $wpmem_fields[ $row ][2] == wpmem_get( 'field', false, 'get' ) ) {
796
+ $arr[0] = $wpmem_fields[ $row ][0];
797
+ foreach ( $arr as $key => $value ) {
798
+ $wpmem_fields[ $row ][ $key ] = $arr[ $key ];
799
+ }
800
  }
801
+ }
802
+ $did_update = sprintf( __( '%s was updated', 'wp-members' ), $add_name );
803
+ $did_update.= '<p><a href="' . add_query_arg( array( 'page' => 'wpmem-settings', 'tab' => 'fields' ), get_admin_url() . 'options-general.php' ) . '">&laquo; ' . __( 'Return to Fields Table', 'wp-members' ) . '</a></p>';
804
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
805
 
806
+ $wpmem_newfields = $wpmem_fields;
807
 
808
+ update_option( 'wpmembers_fields', $wpmem_newfields );
809
+ $wpmem->load_fields();
810
+ return $did_update;
811
+ }
812
+ }
813
+ }
814
 
815
  /**
816
+ * Reorders form fields.
 
 
817
  *
818
+ * @since 2.5.1
819
+ * @since 3.1.8 Rebuilt for new List Table.
820
  */
821
+ function wpmem_a_field_reorder() {
822
+
823
+ // Start fresh.
824
+ $new_order = $wpmem_fields = $field = $key = $wpmem_new_fields = $id = $k = '';
825
+ $wpmem_fields = get_option( 'wpmembers_fields' );
826
+
827
+ // Get the list items
828
+ $new_order = $_POST;
829
+
830
+ // Put fields in the proper order for the current form.
831
+ $wpmem_new_fields = array();
832
+ foreach ( $new_order['list_items'] as $id ) {
833
+ foreach( $wpmem_fields as $val ) {
834
+ if ( $val[0] == $id ) {
835
+ $wpmem_new_fields[] = $val;
836
+ }
837
+ }
838
+ }
839
+
840
+ // Save fields array with new current form field order.
841
+ update_option( 'wpmembers_fields', $wpmem_new_fields );
842
+
843
+ // Indicate successful transaction.
844
+ _e( 'Form field order updated.', 'wp-members' );
845
+
846
+ die(); // This is required to return a proper result.
847
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
848
  }
849
 
850
  // End of file.
admin/tab-options.php CHANGED
@@ -70,7 +70,7 @@ function wpmem_a_build_options() {
70
  <div class="postbox">
71
  <h3><span><?php _e( 'Manage Options', 'wp-members' ); ?></span></h3>
72
  <div class="inside">
73
- <form name="updatesettings" id="updatesettings" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
74
  <?php wp_nonce_field( 'wpmem-update-settings' ); ?>
75
  <h3><?php _e( 'Content', 'wp-members' ); ?></h3>
76
  <ul>
@@ -246,7 +246,7 @@ function wpmem_a_build_options() {
246
  <div class="postbox">
247
  <h3><span><?php _e( 'Custom Post Types', 'wp-members' ); ?></span></h3>
248
  <div class="inside">
249
- <form name="updatecpts" id="updatecpts" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
250
  <?php wp_nonce_field( 'wpmem-update-cpts' ); ?>
251
  <table class="form-table">
252
  <tr>
70
  <div class="postbox">
71
  <h3><span><?php _e( 'Manage Options', 'wp-members' ); ?></span></h3>
72
  <div class="inside">
73
+ <form name="updatesettings" id="updatesettings" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
74
  <?php wp_nonce_field( 'wpmem-update-settings' ); ?>
75
  <h3><?php _e( 'Content', 'wp-members' ); ?></h3>
76
  <ul>
246
  <div class="postbox">
247
  <h3><span><?php _e( 'Custom Post Types', 'wp-members' ); ?></span></h3>
248
  <div class="inside">
249
+ <form name="updatecpts" id="updatecpts" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
250
  <?php wp_nonce_field( 'wpmem-update-cpts' ); ?>
251
  <table class="form-table">
252
  <tr>
admin/user-profile.php CHANGED
@@ -93,9 +93,13 @@ function wpmem_admin_fields() {
93
  } else {
94
  $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file;
95
  }
96
- // @todo - come up with a way to handle file updates - user profile form does not support multitype
97
- //$show_field.= ' <span class="description">' . __( 'Update this file:' ) . '</span><br />';
98
- //$show_field.= wpmem_create_formfield( $meta[2] . '_update_file', $meta[3], $val, $valtochk );
 
 
 
 
99
  } else {
100
  if ( 'select' == $field['type'] || 'radio' == $field['type'] ) {
101
  $input = wpmem_create_formfield( $meta, $field['type'], $values, $valtochk );
@@ -236,7 +240,7 @@ function wpmem_admin_update() {
236
  $fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? implode( $field['delimiter'], $_POST[ $meta ] ) : '';
237
  }
238
  }
239
-
240
  /**
241
  * Filter the submitted field values for backend profile update.
242
  *
@@ -254,6 +258,10 @@ function wpmem_admin_update() {
254
  update_user_meta( $user_id, $key, $val );
255
  }
256
  }
 
 
 
 
257
 
258
  if ( $wpmem->mod_reg == 1 ) {
259
 
93
  } else {
94
  $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file;
95
  }
96
+ $input.= '<br />' . $wpmem->get_text( 'profile_upload' ) . '<br />';
97
+ $input.= wpmem_form_field( array(
98
+ 'name' => $meta,
99
+ 'type' => $field['type'],
100
+ 'value' => $val,
101
+ 'compare' => $valtochk,
102
+ ) );
103
  } else {
104
  if ( 'select' == $field['type'] || 'radio' == $field['type'] ) {
105
  $input = wpmem_create_formfield( $meta, $field['type'], $values, $valtochk );
240
  $fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? implode( $field['delimiter'], $_POST[ $meta ] ) : '';
241
  }
242
  }
243
+
244
  /**
245
  * Filter the submitted field values for backend profile update.
246
  *
258
  update_user_meta( $user_id, $key, $val );
259
  }
260
  }
261
+
262
+ if ( ! empty( $_FILES ) ) {
263
+ $wpmem->user->upload_user_files( $user_id, $wpmem->fields );
264
+ }
265
 
266
  if ( $wpmem->mod_reg == 1 ) {
267
 
admin/users.php CHANGED
@@ -206,7 +206,7 @@ function wpmem_users_admin_notices() {
206
 
207
  global $pagenow, $user_action_msg;
208
  if( $pagenow == 'users.php' && isset( $_REQUEST['activated'] ) ) {
209
- $message = $_REQUEST['activated'];
210
  echo "<div class=\"updated\"><p>{$message}</p></div>";
211
  }
212
 
206
 
207
  global $pagenow, $user_action_msg;
208
  if( $pagenow == 'users.php' && isset( $_REQUEST['activated'] ) ) {
209
+ $message = esc_html( $_REQUEST['activated'] );
210
  echo "<div class=\"updated\"><p>{$message}</p></div>";
211
  }
212
 
changelog.txt CHANGED
@@ -1,4 +1,32 @@
1
- = 3.1.5 =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  * Addressed some security issues to prevent XSS vulnerabilities.
4
  * Updated [wpmem_show_count] shortcode to include count of total blog users and users by role. See: http://rkt.bz/xC
1
+ = 3.1.6 =
2
+
3
+ * Fixed [wpmem_field] display handling for multiple select and multiple checkbox field types.
4
+ * Updates to always load fields from wpmem_fields() API function.
5
+ * Updates to begin to utilize new fields settings array. Fields setting is still store in the same array format as before. However, it is loaded into the new settings format. Current object class keeps numeric keys in place for legacy purposes.
6
+ * Updates to dropdown handling on main options tab to display proper preselected value when site is using ssl (https://) and no value is selected.
7
+ * Added wpmem_loginout() API function, changed [wpmem_loginout] shortcode to use API function.
8
+ * Added wpmem_array_insert() API function, allows for inserting array elements at any point in an array.
9
+ * Added wp_destroy_current_session() to logout function.
10
+ * Added WooCommerce support in native WP registration functions. Began adding WooCommerce classes to registration form elements.
11
+ * Added to wpmem_user_has_role() function to check for a single role or if the user has a role that is in an array of roles.
12
+ * Added wpmem_shortcodes_loaded, wpmem_hooks_loaded, and wpmem_dropins_loaded to fire after.
13
+ * Added text input to set a default 'read more' link for auto excerpt.
14
+ * Fixed issue with auto excerpt where an excerpt shorter than the excerpt setting would not display the more link.
15
+ * Preliminary updates to include placeholder support in fields (this will be an option in a future release).
16
+ * Localization fix of untranslated strings.
17
+ * Wrap "Remember Me" checkbox label with label tag in login form.
18
+ * Moved remaining initialization functions to class constructor.
19
+ * Moved wpmem_load_shortcodes, wpmem_load_hooks, and wpmem_load_dropins to fire before.
20
+ * reCAPTCHA version 1 is no longer supported by Google. It is now deprecated in the plugin. If you have reCAPTCHA v1 selected, it will remain so. But once this is changed to a different CAPTCHA setting or if this is a new install, reCAPTCHA version 1 will no longer be available as a selection.
21
+ * Custom field term "Option Name" changed to "Meta Key" for clarity.
22
+ * Marked required custom field properties as required in Add/Edit Field dialogs.
23
+ * 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.
24
+ * Fixes issue with displaying checkbox state on the admin user profile screen.
25
+ * Fixes issue with auto excerpt when excerpts are displayed on single posts/pages.
26
+ * 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).
27
+ * Applies some admin strings for translation.
28
+
29
+ = 3.1.5 =
30
 
31
  * Addressed some security issues to prevent XSS vulnerabilities.
32
  * Updated [wpmem_show_count] shortcode to include count of total blog users and users by role. See: http://rkt.bz/xC
css/generic-no-float.css CHANGED
@@ -97,6 +97,8 @@ see http://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
97
  #wpmem_reg input[type="password"],
98
  #wpmem_reg input[type="email"],
99
  #wpmem_reg input[type="url"],
 
 
100
  #wpmem_reg textarea,
101
  #wpmem_login input[type="text"],
102
  #wpmem_login input[type="password"] {
@@ -148,6 +150,7 @@ see http://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
148
  line-height: 1;
149
  font-weight: 700;
150
  margin-bottom: 10px;
 
151
  }
152
  #wpmem_reg .form,
153
  #wpmem_login .form {
@@ -173,7 +176,9 @@ see http://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
173
  #wpmem_reg .div_radio,
174
  #wpmem_reg .div_image,
175
  #wpmem_reg .div_file,
176
- #wpmem_reg .div_url {
 
 
177
  width:74%;
178
  margin:0 0 14px 0;
179
  }
97
  #wpmem_reg input[type="password"],
98
  #wpmem_reg input[type="email"],
99
  #wpmem_reg input[type="url"],
100
+ #wpmem_reg input[type="number"],
101
+ #wpmem_reg input[type="date"],
102
  #wpmem_reg textarea,
103
  #wpmem_login input[type="text"],
104
  #wpmem_login input[type="password"] {
150
  line-height: 1;
151
  font-weight: 700;
152
  margin-bottom: 10px;
153
+ width: 100%;
154
  }
155
  #wpmem_reg .form,
156
  #wpmem_login .form {
176
  #wpmem_reg .div_radio,
177
  #wpmem_reg .div_image,
178
  #wpmem_reg .div_file,
179
+ #wpmem_reg .div_url,
180
+ #wpmem_reg .div_number,
181
+ #wpmem_reg .div_date {
182
  width:74%;
183
  margin:0 0 14px 0;
184
  }
css/wp-members-2014-no-float.css CHANGED
@@ -115,7 +115,9 @@ see http://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
115
  #wpmem_reg .div_radio,
116
  #wpmem_reg .div_image,
117
  #wpmem_reg .div_file,
118
- #wpmem_reg .div_url{
 
 
119
  width:74%;
120
  margin:0 0 14px 0;
121
  }
115
  #wpmem_reg .div_radio,
116
  #wpmem_reg .div_image,
117
  #wpmem_reg .div_file,
118
+ #wpmem_reg .div_url,
119
+ #wpmem_reg .div_number,
120
+ #wpmem_reg .div_date {
121
  width:74%;
122
  margin:0 0 14px 0;
123
  }
css/wp-members-2015-no-float.css CHANGED
@@ -146,7 +146,9 @@ see http://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
146
  #wpmem_reg .div_radio,
147
  #wpmem_reg .div_url,
148
  #wpmem_reg .div_image,
149
- #wpmem_reg .div_file {
 
 
150
  width:74%;
151
  margin:0 0 14px 0;
152
  }
146
  #wpmem_reg .div_radio,
147
  #wpmem_reg .div_url,
148
  #wpmem_reg .div_image,
149
+ #wpmem_reg .div_file,
150
+ #wpmem_reg .div_number,
151
+ #wpmem_reg .div_date {
152
  width:74%;
153
  margin:0 0 14px 0;
154
  }
css/wp-members-2016-no-float.css CHANGED
@@ -154,7 +154,9 @@ see http://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
154
  #wpmem_reg .div_radio,
155
  #wpmem_reg .div_url,
156
  #wpmem_reg .div_file,
157
- #wpmem_reg .div_image {
 
 
158
  width:74%;
159
  margin:0 0 14px 0;
160
  }
154
  #wpmem_reg .div_radio,
155
  #wpmem_reg .div_url,
156
  #wpmem_reg .div_file,
157
+ #wpmem_reg .div_image,
158
+ #wpmem_reg .div_number,
159
+ #wpmem_reg .div_date {
160
  width:74%;
161
  margin:0 0 14px 0;
162
  }
inc/api.php CHANGED
@@ -288,6 +288,7 @@ function wpmem_use_custom_dialog( $defaults, $tag, $dialogs ) {
288
  * @since 3.1.6 Include accepting an array of roles to check.
289
  *
290
  * @global object $current_user Current user object.
 
291
  * @param string|array $role Slug or array of slugs of the role being checked.
292
  * @param int $user_id ID of the user being checked (optional).
293
  * @return boolean $has_role True if user has the role, otherwise false.
@@ -312,6 +313,30 @@ function wpmem_user_has_role( $role, $user_id = false ) {
312
  }
313
  }
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  /**
316
  * Creates a membership number.
317
  *
288
  * @since 3.1.6 Include accepting an array of roles to check.
289
  *
290
  * @global object $current_user Current user object.
291
+ * @global object $wpmem WP_Members object.
292
  * @param string|array $role Slug or array of slugs of the role being checked.
293
  * @param int $user_id ID of the user being checked (optional).
294
  * @return boolean $has_role True if user has the role, otherwise false.
313
  }
314
  }
315
 
316
+ /**
317
+ * Checks if a user has a given meta value.
318
+ *
319
+ * @since 3.1.8
320
+ *
321
+ * @global object $wpmem WP_Members object.
322
+ * @param string $meta Meta key being checked.
323
+ * @param string $value Value the meta key should have (optional).
324
+ * @param int $user_id ID of the user being checked (optional).
325
+ * @return boolean $has_meta True if user has the meta value, otherwise false.
326
+ */
327
+ function wpmem_user_has_meta( $meta, $value = false, $user_id = false ) {
328
+ global $wpmem;
329
+ $user_id = ( $user_id ) ? $user_id : get_current_user_id();
330
+ $has_meta = false;
331
+ $user_value = get_user_meta( $user_id, $meta, true );
332
+ if ( $value ) {
333
+ $has_meta = ( $user_value == $value ) ? true : $has_meta;
334
+ } else {
335
+ $has_meta = ( $value ) ? true : $has_meta;
336
+ }
337
+ return $has_meta;
338
+ }
339
+
340
  /**
341
  * Creates a membership number.
342
  *
inc/class-wp-members-api.php CHANGED
@@ -62,6 +62,37 @@ class WP_Members_API {
62
  }
63
  return $display_values;
64
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  /**
67
  * Checks that a given user field value is unique.
62
  }
63
  return $display_values;
64
  }
65
+
66
+ /**
67
+ * Gets the display/label value of a field.
68
+ *
69
+ * @since 3.1.8
70
+ *
71
+ * @param string $meta The field meta key.
72
+ * @param string $user_id The user's ID.
73
+ * @param string $value The field's value, if given.
74
+ * @return string $value The display value.
75
+ */
76
+ function get_field_display_value( $meta, $user_id, $value = null ) {
77
+ global $wpmem;
78
+ $fields = ( isset( $wpmem->fields ) ) ? $wpmem->fields : wpmem_fields();
79
+ $field = $fields[ $meta ];
80
+ $value = ( $value ) ? $value : get_user_meta( $user_id, $meta, true );
81
+ switch ( $field['type'] ) {
82
+ case 'multiselect':
83
+ case 'multicheckbox':
84
+ break;
85
+ case 'select':
86
+ case 'radio':
87
+ $value = $fields[ $meta ]['options'][ $value ];
88
+ break;
89
+ case 'image':
90
+ case 'file':
91
+ $value = wp_get_attachment_url( $value );
92
+ break;
93
+ }
94
+ return $value;
95
+ }
96
 
97
  /**
98
  * Checks that a given user field value is unique.
inc/class-wp-members-forms.php CHANGED
@@ -66,6 +66,7 @@ class WP_Members_Forms {
66
  case "url":
67
  case "email":
68
  case "number":
 
69
  $class = ( 'textbox' == $class ) ? "textbox" : $class;
70
  switch ( $type ) {
71
  case 'url':
@@ -74,8 +75,8 @@ class WP_Members_Forms {
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;
@@ -84,8 +85,8 @@ class WP_Members_Forms {
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
 
@@ -106,7 +107,7 @@ class WP_Members_Forms {
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';
@@ -313,11 +314,12 @@ class WP_Members_Forms {
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
@@ -485,22 +487,26 @@ class WP_Members_Forms {
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.
@@ -510,7 +516,7 @@ class WP_Members_Forms {
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.
@@ -522,7 +528,26 @@ class WP_Members_Forms {
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
 
@@ -571,14 +596,15 @@ class WP_Members_Forms {
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.
@@ -745,10 +771,6 @@ class WP_Members_Forms {
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,
@@ -766,7 +788,8 @@ class WP_Members_Forms {
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':
@@ -775,7 +798,7 @@ class WP_Members_Forms {
775
  break;
776
 
777
  case 'user_url':
778
- $val = esc_url( $userdata->user_url );
779
  break;
780
 
781
  case 'display_name':
@@ -860,7 +883,6 @@ class WP_Members_Forms {
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,
@@ -1090,7 +1112,7 @@ class WP_Members_Forms {
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.
@@ -1134,6 +1156,34 @@ class WP_Members_Forms {
1134
 
1135
  // Return the generated form.
1136
  return $form;
1137
- } // End wpmem_inc_registration.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1138
 
1139
  } // End of WP_Members_Forms class.
66
  case "url":
67
  case "email":
68
  case "number":
69
+ case "date":
70
  $class = ( 'textbox' == $class ) ? "textbox" : $class;
71
  switch ( $type ) {
72
  case 'url':
75
  case 'email':
76
  $value = esc_attr( wp_unslash( $value ) );
77
  break;
78
+ //case 'number':
79
+ //$value = esc_attr( $value );
80
  default:
81
  $value = stripslashes( esc_attr( $value ) );
82
  break;
85
  $placeholder = ( $placeholder ) ? ' placeholder="' . $placeholder . '"' : '';
86
  $pattern = ( $pattern ) ? ' pattern="' . $pattern . '"' : '';
87
  $title = ( $title ) ? ' title="' . $title . '"' : '';
88
+ $min = ( isset( $args['min'] ) && $args['min'] != '' ) ? ' min="' . $args['min'] . '"' : '';
89
+ $max = ( isset( $args['max'] ) && $args['max'] != '' ) ? ' max="' . $args['max'] . '"' : '';
90
  $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" value=\"$value\" class=\"$class\"$placeholder$title$pattern$min$max" . ( ( $required ) ? " required " : "" ) . " />";
91
  break;
92
 
107
  break;
108
 
109
  case "textarea":
110
+ $value = stripslashes( $value ); // stripslashes( esc_textarea( $value ) );
111
  $class = ( 'textbox' == $class ) ? "textarea" : $class;
112
  $rows = ( isset( $args['rows'] ) ) ? $args['rows'] : '5';
113
  $cols = ( isset( $args['cols'] ) ) ? $args['cols'] : '20';
314
  }
315
 
316
  /**
317
+ * Login Form Builder.
318
  *
319
  * Builds the form used for login, change password, and reset password.
320
  *
321
  * @since 2.5.1
322
+ * @since 3.1.7 Moved to forms object class as login_form().
323
  * @since 3.1.7 Added WP action login_form.
324
  *
325
  * @param string $page
487
 
488
  $links_array = array(
489
  'forgot' => array(
490
+ 'tag' => 'forgot',
491
  'link' => add_query_arg( 'a', 'pwdreset', $wpmem->user_pages['profile'] ),
492
  'page' => 'profile',
493
  'action' => 'login',
494
  ),
495
+ 'register' => array(
496
+ 'tag' => 'reg',
497
  'link' => $wpmem->user_pages['register'],
498
  'page' => 'register',
499
  'action' => 'login',
500
  ),
501
  'username' => array(
502
+ 'tag' => 'username',
503
  'link' => add_query_arg( 'a', 'getusername', $wpmem->user_pages['profile'] ),
504
  'page' => 'profile',
505
  'action' => 'pwdreset',
506
  ),
507
  );
508
  foreach ( $links_array as $key => $value ) {
509
+ $tag = $value['tag'];
510
  if ( ( $wpmem->user_pages[ $value['page'] ] || 'members' == $page ) && $value['action'] == $arr['action'] ) {
511
  /**
512
  * Filters register, forgot password, and forgot username links.
516
  *
517
  * @param string The raw link.
518
  */
519
+ $link = apply_filters( "wpmem_{$tag}_link", $value['link'] );
520
  $str = $wpmem->get_text( "{$key}_link_before" ) . '<a href="' . $link . '">' . $wpmem->get_text( "{$key}_link" ) . '</a>';
521
  /**
522
  * Filters the register, forgot password, and forgot username links HTML.
528
  * @param string $str The link HTML.
529
  * @param string $link The link.
530
  */
531
+ $link = $args['link_before'] . apply_filters( "wpmem_{$tag}_link_str", $str, $link ) . $args['link_after'] . $args['n'];
532
+ /*
533
+ * If this is the register link, and the current post type is set to
534
+ * display the register form, and the current page is not the login
535
+ * page, then do not add the register link, otherwise add the link.
536
+ */
537
+ if ( 'register' == $key ) {
538
+ if ( isset( $wpmem->user_pages['login'] ) && $wpmem->user_pages['login'] != '' ) {
539
+ $form = ( 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && wpmem_current_url() != wpmem_login_url() ) ? $form : $form . $link;
540
+ } else {
541
+ global $post;
542
+ if ( has_shortcode( $post->post_content, 'wpmem_profile' ) ) {
543
+ $form = $form;
544
+ } else {
545
+ $form = ( 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && ! has_shortcode( $post->post_content, 'wpmem_form' ) ) ? $form : $form . $link;
546
+ }
547
+ }
548
+ } else {
549
+ $form = $form . $link;
550
+ }
551
  }
552
  }
553
 
596
  $form = apply_filters( 'wpmem_login_form_before', '', $arr['action'] ) . $form;
597
 
598
  return $form;
599
+ } // End login_form.
600
 
601
  /**
602
+ * Registration Form Builder.
603
  *
604
  * Outputs the form for new user registration and existing user edits.
605
  *
606
  * @since 2.5.1
607
+ * @since 3.1.7 Moved to forms object class as register_form().
608
  *
609
  * @global object $wpmem The WP_Members object.
610
  * @global string $wpmem_regchk Used to determine if the form is in an error state.
771
  if ( $meta_key != 'tos' ) {
772
 
773
  $class = ( $field['type'] == 'password' || $field['type'] == 'email' || $field['type'] == 'url' ) ? 'text' : $field['type'];
 
 
 
 
774
 
775
  $label = wpmem_form_label( array(
776
  'meta_key' => $meta_key,
788
 
789
  switch ( $meta_key ) {
790
  case( 'description' ):
791
+ case( 'textarea' == $field['type'] ):
792
+ $val = get_user_meta( $userdata->ID, $meta_key, 'true' ); // esc_textarea() is run when field is created.
793
  break;
794
 
795
  case 'user_email':
798
  break;
799
 
800
  case 'user_url':
801
+ $val = $userdata->user_url; // esc_url() is run when the field is created.
802
  break;
803
 
804
  case 'display_name':
883
  } else {
884
  $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file;
885
  }
 
886
  $input.= '<br />' . $wpmem->get_text( 'profile_upload' ) . '<br />';
887
  $input.= wpmem_form_field( array(
888
  'name' => $meta_key,
1112
  $form = $args['txt_before'] . $form . $args['txt_after'];
1113
 
1114
  // Remove line breaks if enabled for easier filtering later.
1115
+ $form = ( $args['strip_breaks'] ) ? $this->strip_breaks( $form, $rows ) : $form; //str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
1116
 
1117
  /**
1118
  * Filter the generated HTML of the entire form.
1156
 
1157
  // Return the generated form.
1158
  return $form;
1159
+ } // End register_form().
1160
+
1161
+ /**
1162
+ * Strip line breaks from form.
1163
+ *
1164
+ * Function removes line breaks and tabs. Checks for textarea fields
1165
+ * before stripping line breaks.
1166
+ *
1167
+ * @since 3.1.8
1168
+ *
1169
+ * @param string $form
1170
+ * @param array $rows
1171
+ * @return string $form
1172
+ */
1173
+ function strip_breaks( $form, $rows ) {
1174
+ foreach( $rows as $key => $row ) {
1175
+ if ( 'textarea' == $row['type'] ) {
1176
+ $textareas[ $key ] = $row['field'];
1177
+ }
1178
+ }
1179
+ $form = str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form );
1180
+ if ( ! empty ( $textareas ) ) {
1181
+ foreach ( $textareas as $textarea ) {
1182
+ $stripped = str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $textarea );
1183
+ $form = str_replace( $stripped, $textarea, $form );
1184
+ }
1185
+ }
1186
+ return $form;
1187
+ }
1188
 
1189
  } // End of WP_Members_Forms class.
inc/class-wp-members-user.php CHANGED
@@ -156,18 +156,7 @@ class WP_Members_User {
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
  /**
@@ -332,4 +321,58 @@ class WP_Members_User {
332
  return;
333
  }
334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  }
156
 
157
  // Handle file uploads, if any.
158
  if ( ! empty( $_FILES ) ) {
159
+ $this->upload_user_files( $user_id, $wpmem->fields );
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
 
162
  /**
321
  return;
322
  }
323
 
324
+ /**
325
+ * Handles retrieving a forgotten username.
326
+ *
327
+ * @since 3.0.8
328
+ * @since 3.1.6 Dependencies now loaded by object.
329
+ * @since 3.1.8 Moved to user object.
330
+ *
331
+ * @return string $regchk The regchk value.
332
+ */
333
+ function retrieve_username() {
334
+ if ( isset( $_POST['formsubmit'] ) ) {
335
+ $email = sanitize_email( $_POST['user_email'] );
336
+ $user = ( isset( $_POST['user_email'] ) ) ? get_user_by( 'email', $email ) : false;
337
+ if ( $user ) {
338
+ // Send it in an email.
339
+ wpmem_inc_regemail( $user->ID, '', 4 );
340
+ /**
341
+ * Fires after retrieving username.
342
+ *
343
+ * @since 3.0.8
344
+ *
345
+ * @param int $user_ID The user's numeric ID.
346
+ */
347
+ do_action( 'wpmem_get_username', $user->ID );
348
+ return 'usernamesuccess';
349
+ } else {
350
+ return 'usernamefailed';
351
+ }
352
+ }
353
+ return;
354
+ }
355
+
356
+ /**
357
+ * Handle user file uploads for registration and profile update.
358
+ *
359
+ * @since 3.1.8
360
+ *
361
+ * @param string $user_id
362
+ * @param array $fields
363
+ */
364
+ function upload_user_files( $user_id, $fields ) {
365
+ global $wpmem;
366
+ foreach ( $fields as $meta_key => $field ) {
367
+ if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && is_array( $_FILES[ $meta_key ] ) ) {
368
+ if ( ! empty( $_FILES[ $meta_key ]['name'] ) ) {
369
+ // Upload the file and save it as an attachment.
370
+ $file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $user_id );
371
+ // Save the attachment ID as user meta.
372
+ update_user_meta( $user_id, $meta_key, $file_post_id );
373
+ }
374
+ }
375
+ }
376
+ }
377
+
378
  }
inc/class-wp-members.php CHANGED
@@ -311,12 +311,13 @@ class WP_Members {
311
  add_action( 'wp_print_styles', 'wpmem_enqueue_style' ); // load the stylesheet if using the new forms
312
 
313
  // Add filters.
314
- add_filter( 'the_content', array( $this, 'do_securify' ), 99 );
315
- add_filter( 'allow_password_reset', 'wpmem_no_reset' ); // no password reset for non-activated users
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 ) {
@@ -425,10 +426,12 @@ class WP_Members {
425
  require_once( WPMEM_PATH . 'inc/core.php' );
426
  require_once( WPMEM_PATH . 'inc/api.php' );
427
  require_once( WPMEM_PATH . 'inc/utilities.php' );
 
428
  require_once( WPMEM_PATH . 'inc/dialogs.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
 
@@ -510,23 +513,23 @@ class WP_Members {
510
  switch ( $action ) {
511
 
512
  case 'login':
513
- $regchk = wpmem_login();
514
  break;
515
 
516
  case 'logout':
517
- $regchk = wpmem_logout();
518
  break;
519
 
520
  case 'pwdchange':
521
- $regchk = wpmem_change_password();
522
  break;
523
 
524
  case 'pwdreset':
525
- $regchk = wpmem_reset_password();
526
  break;
527
 
528
  case 'getusername':
529
- $regchk = wpmem_retrieve_username();
530
  break;
531
 
532
  case 'register':
311
  add_action( 'wp_print_styles', 'wpmem_enqueue_style' ); // load the stylesheet if using the new forms
312
 
313
  // Add filters.
314
+ add_filter( 'the_content', array( $this, 'do_securify' ), 99 );
315
+ add_filter( 'allow_password_reset', 'wpmem_no_reset' ); // no password reset for non-activated users
316
+ add_filter( 'register_form', 'wpmem_wp_register_form' ); // adds fields to the default wp registration
317
+ add_action( 'woocommerce_register_form', 'wpmem_woo_register_form' );
318
+ add_filter( 'registration_errors', 'wpmem_wp_reg_validate', 10, 3 ); // native registration validation
319
+ add_filter( 'comments_open', 'wpmem_securify_comments', 99 ); // securifies the comments
320
+ add_filter( 'wpmem_securify', 'wpmem_reg_securify' ); // adds success message on login form if redirected
321
 
322
  // If registration is moderated, check for activation (blocks backend login by non-activated users).
323
  if ( $this->mod_reg == 1 ) {
426
  require_once( WPMEM_PATH . 'inc/core.php' );
427
  require_once( WPMEM_PATH . 'inc/api.php' );
428
  require_once( WPMEM_PATH . 'inc/utilities.php' );
429
+ require_once( WPMEM_PATH . 'inc/forms.php' );
430
  require_once( WPMEM_PATH . 'inc/dialogs.php' );
431
  require_once( WPMEM_PATH . 'inc/sidebar.php' );
432
  require_once( WPMEM_PATH . 'inc/shortcodes.php' );
433
  require_once( WPMEM_PATH . 'inc/email.php' );
434
+ require_once( WPMEM_PATH . 'inc/users.php' );
435
  require_once( WPMEM_PATH . 'inc/deprecated.php' );
436
  }
437
 
513
  switch ( $action ) {
514
 
515
  case 'login':
516
+ $regchk = $this->user->login();
517
  break;
518
 
519
  case 'logout':
520
+ $regchk = $this->user->logout();
521
  break;
522
 
523
  case 'pwdchange':
524
+ $regchk = $this->user->password_update( 'change' );
525
  break;
526
 
527
  case 'pwdreset':
528
+ $regchk = $this->user->password_update( 'reset' );
529
  break;
530
 
531
  case 'getusername':
532
+ $regchk = $this->user->retrieve_username();
533
  break;
534
 
535
  case 'register':
inc/core.php CHANGED
@@ -213,13 +213,14 @@ endif;
213
  * Add registration fields to the native WP registration.
214
  *
215
  * @since 2.8.3
 
216
  */
217
- function wpmem_wp_register_form() {
218
  /**
219
  * Load native WP registration functions.
220
  */
221
  require_once( WPMEM_PATH . 'inc/wp-registration.php' );
222
- wpmem_do_wp_register_form();
223
  }
224
 
225
 
@@ -372,37 +373,15 @@ function wpmem_securify_comments_array( $comments , $post_id ) {
372
  *
373
  * @since 3.0.8
374
  * @since 3.1.6 Dependencies now loaded by object.
 
 
 
375
  *
376
  * @return string $regchk The regchk value.
377
  */
378
  function wpmem_retrieve_username() {
379
-
380
- if ( isset( $_POST['formsubmit'] ) ) {
381
-
382
- $email = sanitize_email( $_POST['user_email'] );
383
- $user = ( isset( $_POST['user_email'] ) ) ? get_user_by( 'email', $email ) : false;
384
-
385
- if ( $user ) {
386
-
387
- // Send it in an email.
388
- wpmem_inc_regemail( $user->ID, '', 4 );
389
-
390
- /**
391
- * Fires after retrieving username.
392
- *
393
- * @since 3.0.8
394
- *
395
- * @param int $user_ID The user's numeric ID.
396
- */
397
- do_action( 'wpmem_get_username', $user->ID );
398
-
399
- return 'usernamesuccess';
400
-
401
- } else {
402
- return 'usernamefailed';
403
- }
404
- }
405
- return;
406
  }
407
 
408
 
213
  * Add registration fields to the native WP registration.
214
  *
215
  * @since 2.8.3
216
+ * @since 3.1.8 Added $process argument.
217
  */
218
+ function wpmem_wp_register_form( $process = 'wp' ) {
219
  /**
220
  * Load native WP registration functions.
221
  */
222
  require_once( WPMEM_PATH . 'inc/wp-registration.php' );
223
+ wpmem_do_wp_register_form( $process );
224
  }
225
 
226
 
373
  *
374
  * @since 3.0.8
375
  * @since 3.1.6 Dependencies now loaded by object.
376
+ * @since 3.1.8 Now a wrapper for $wpmem->retrieve_username() in WP_Members_Users Class.
377
+ *
378
+ * @global object $wpmem The WP-Members object class.
379
  *
380
  * @return string $regchk The regchk value.
381
  */
382
  function wpmem_retrieve_username() {
383
+ global $wpmem;
384
+ return $wpmem->user->retrieve_username();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  }
386
 
387
 
inc/deprecated.php CHANGED
@@ -1,188 +1,344 @@
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;
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;
189
+
190
+
191
+ if ( ! function_exists( 'wpmem_do_sc_pages' ) ):
192
+ /**
193
+ * Builds the shortcode pages (login, register, user-profile, user-edit, password).
194
+ *
195
+ * Some of the logic here is similar to the wpmem_securify() function.
196
+ * But where that function handles general content, this function
197
+ * handles building specific pages generated by shortcodes.
198
+ *
199
+ * @since 2.6.0
200
+ * @deprecated 3.1.8 Use wpmem_sc_user_profile() or wpmem_sc_forms() instead.
201
+ *
202
+ * @global object $wpmem The WP_Members object.
203
+ * @global string $wpmem_themsg The WP-Members message container.
204
+ * @global object $post The WordPress post object.
205
+ *
206
+ * @param string $atts {
207
+ * The shortcode attributes.
208
+ *
209
+ * @type string $page
210
+ * @type string $redirect_to
211
+ * @type string $register
212
+ * }
213
+ * @param string $content
214
+ * @param string $tag
215
+ * @return string $content
216
+ */
217
+ function wpmem_do_sc_pages( $atts, $content, $tag ) {
218
+
219
+ $page = ( isset( $atts['page'] ) ) ? $atts['page'] : $tag;
220
+ $redirect_to = ( isset( $atts['redirect_to'] ) ) ? $atts['redirect_to'] : null;
221
+ $hide_register = ( isset( $atts['register'] ) && 'hide' == $atts['register'] ) ? true : false;
222
+
223
+ global $wpmem, $wpmem_themsg, $post;
224
+ include_once( WPMEM_PATH . 'inc/dialogs.php' );
225
+
226
+ $content = '';
227
+
228
+ // Deprecating members-area parameter to be replaced by user-profile.
229
+ $page = ( $page == 'user-profile' ) ? 'members-area' : $page;
230
+
231
+ if ( $page == 'members-area' || $page == 'register' ) {
232
+
233
+ if ( $wpmem->regchk == "captcha" ) {
234
+ global $wpmem_captcha_err;
235
+ $wpmem_themsg = __( 'There was an error with the CAPTCHA form.' ) . '<br /><br />' . $wpmem_captcha_err;
236
+ }
237
+
238
+ if ( $wpmem->regchk == "loginfailed" ) {
239
+ return wpmem_inc_loginfailed();
240
+ }
241
+
242
+ if ( ! is_user_logged_in() ) {
243
+ if ( $wpmem->action == 'register' && ! $hide_register ) {
244
+
245
+ switch( $wpmem->regchk ) {
246
+
247
+ case "success":
248
+ $content = wpmem_inc_regmessage( $wpmem->regchk,$wpmem_themsg );
249
+ $content = $content . wpmem_inc_login();
250
+ break;
251
+
252
+ default:
253
+ $content = wpmem_inc_regmessage( $wpmem->regchk,$wpmem_themsg );
254
+ $content = $content . wpmem_inc_registration();
255
+ break;
256
+ }
257
+
258
+ } elseif ( $wpmem->action == 'pwdreset' ) {
259
+
260
+ $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
261
+
262
+ } elseif( $wpmem->action == 'getusername' ) {
263
+
264
+ $content = wpmem_page_forgot_username( $wpmem->regchk, $content );
265
+
266
+ } else {
267
+
268
+ $content = ( $page == 'members-area' ) ? $content . wpmem_inc_login( 'members' ) : $content;
269
+ $content = ( ( $page == 'register' || $wpmem->show_reg[ $post->post_type ] != 0 ) && ! $hide_register ) ? $content . wpmem_inc_registration() : $content;
270
+ }
271
+
272
+ } elseif ( is_user_logged_in() && $page == 'members-area' ) {
273
+
274
+ /**
275
+ * Filter the default heading in User Profile edit mode.
276
+ *
277
+ * @since 2.7.5
278
+ *
279
+ * @param string The default edit mode heading.
280
+ */
281
+ $heading = apply_filters( 'wpmem_user_edit_heading', __( 'Edit Your Information', 'wp-members' ) );
282
+
283
+ switch( $wpmem->action ) {
284
+
285
+ case "edit":
286
+ $content = $content . wpmem_inc_registration( 'edit', $heading );
287
+ break;
288
+
289
+ case "update":
290
+
291
+ // Determine if there are any errors/empty fields.
292
+
293
+ if ( $wpmem->regchk == "updaterr" || $wpmem->regchk == "email" ) {
294
+
295
+ $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
296
+ $content = $content . wpmem_inc_registration( 'edit', $heading );
297
+
298
+ } else {
299
+
300
+ //Case "editsuccess".
301
+ $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
302
+ $content = $content . wpmem_inc_memberlinks();
303
+
304
+ }
305
+ break;
306
+
307
+ case "pwdchange":
308
+
309
+ $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
310
+ break;
311
+
312
+ case "renew":
313
+ $content = wpmem_renew();
314
+ break;
315
+
316
+ default:
317
+ $content = wpmem_inc_memberlinks();
318
+ break;
319
+ }
320
+
321
+ } elseif ( is_user_logged_in() && $page == 'register' ) {
322
+
323
+ $content = $content . wpmem_inc_memberlinks( 'register' );
324
+
325
+ }
326
+
327
+ }
328
+
329
+ if ( $page == 'login' ) {
330
+ $content = ( $wpmem->regchk == "loginfailed" ) ? wpmem_inc_loginfailed() : $content;
331
+ $content = ( ! is_user_logged_in() ) ? $content . wpmem_inc_login( 'login', $redirect_to ) : wpmem_inc_memberlinks( 'login' );
332
+ }
333
+
334
+ if ( $page == 'password' ) {
335
+ $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
336
+ }
337
+
338
+ if ( $page == 'user-edit' ) {
339
+ $content = wpmem_page_user_edit( $wpmem->regchk, $content );
340
+ }
341
+
342
+ return $content;
343
+ } // End wpmem_do_sc_pages.
344
  endif;
inc/dialogs.php CHANGED
@@ -24,10 +24,6 @@
24
  */
25
 
26
 
27
- // Include the form building functions.
28
- include_once( WPMEM_PATH . 'inc/forms.php' );
29
-
30
-
31
  if ( ! function_exists( 'wpmem_inc_loginfailed' ) ):
32
  /**
33
  * Login Failed Dialog.
24
  */
25
 
26
 
 
 
 
 
27
  if ( ! function_exists( 'wpmem_inc_loginfailed' ) ):
28
  /**
29
  * Login Failed Dialog.
inc/forms.php CHANGED
@@ -476,4 +476,27 @@ function wpmem_build_rs_captcha() {
476
  }
477
  }
478
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
479
  // End of file.
476
  }
477
  }
478
 
479
+ /**
480
+ * Add registration fields to WooCommerce registration.
481
+ *
482
+ * As of WooCommerce 3.0, the WC registration process no longer includes the
483
+ * WP register_form action hook. It only includes woocommerce_register_form.
484
+ * In previous versions, WP-Members hooked to register_form for both WP and
485
+ * WC registration. To provide backward compatibility with users who may
486
+ * continue to use updated WP-Members with pre-3.0 WooCommerce, this function
487
+ * checks for WC version and if it is older than 3.0 it will ignore adding
488
+ * the WP-Members form fields as they would have already been added when the
489
+ * register_form action hook fired.
490
+ *
491
+ * @since 3.1.8
492
+ */
493
+ function wpmem_woo_register_form() {
494
+ if ( class_exists( 'WooCommerce' ) ) {
495
+ global $woocommerce;
496
+ if ( version_compare( $woocommerce->version, '3.0', ">=" ) ) {
497
+ wpmem_wp_register_form( 'woo' );
498
+ }
499
+ }
500
+ }
501
+
502
  // End of file.
inc/register.php CHANGED
@@ -271,12 +271,12 @@ function wpmem_registration( $tag ) {
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();
@@ -362,19 +362,7 @@ function wpmem_registration( $tag ) {
362
 
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
- }
378
  }
379
 
380
  // Update wp_update_user fields.
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 ( in_array( 'user_email', $wpmem->fields ) && ! is_email( $wpmem->user->post_data['user_email']) ) {
280
  $wpmem_themsg = $wpmem->get_text( 'reg_valid_email' );
281
  return "updaterr";
282
  exit();
362
 
363
  // Handle file uploads, if any.
364
  if ( ! empty( $_FILES ) ) {
365
+ $wpmem->user->upload_user_files( $wpmem->user->post_data['ID'], $wpmem->fields );
 
 
 
 
 
 
 
 
 
 
 
 
366
  }
367
 
368
  // Update wp_update_user fields.
inc/shortcodes.php CHANGED
@@ -18,7 +18,6 @@
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
24
  * - wpmem_sc_loginout
@@ -44,16 +43,6 @@
44
  function wpmem_sc_forms( $atts, $content = null, $tag = 'wpmem_form' ) {
45
 
46
  global $wpmem, $wpmem_themsg;
47
-
48
- /**
49
- * Load core functions if they are not already loaded.
50
- */
51
- include_once( WPMEM_PATH . 'inc/core.php' );
52
-
53
- /**
54
- * Load dialog functions if they are not already loaded.
55
- */
56
- include_once( WPMEM_PATH . 'inc/dialogs.php' );
57
 
58
  // Defaults.
59
  $redirect_to = ( isset( $atts['redirect_to'] ) ) ? $atts['redirect_to'] : null;
@@ -204,15 +193,13 @@ function wpmem_sc_logged_in( $atts, $content = null, $tag = 'wpmem_logged_in' )
204
  // If there is a "role" attribute and the user has a matching role.
205
  if ( isset( $atts['role'] ) ) {
206
  $roles = explode( ',', $atts['role'] );
207
- foreach ( $roles as $role ) {
208
- if ( in_array( trim( $role ), $current_user->roles ) ) {
209
- $do_return = true;
210
- }
211
  }
212
  }
213
 
214
  // If there is a status attribute of "sub" and the user is logged in.
215
- if ( ( isset( $atts['status'] ) ) && $atts['status'] == 'sub' && is_user_logged_in() ) {
216
  if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) {
217
  if ( ! wpmem_chk_exp() ) {
218
  $do_return = true;
@@ -223,8 +210,16 @@ function wpmem_sc_logged_in( $atts, $content = null, $tag = 'wpmem_logged_in' )
223
  }
224
  }
225
 
226
- // If the current page is the user profile and an action is being handled.
227
- if ( ( wpmem_current_url() == $wpmem->user_pages['profile'] ) && isset( $_GET['a'] ) ) {
 
 
 
 
 
 
 
 
228
  $do_return = false;
229
  }
230
 
@@ -249,160 +244,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_do_sc_pages' ) ):
253
- /**
254
- * Builds the shortcode pages (login, register, user-profile, user-edit, password).
255
- *
256
- * Some of the logic here is similar to the wpmem_securify() function.
257
- * But where that function handles general content, this function
258
- * handles building specific pages generated by shortcodes.
259
- *
260
- * @since 2.6.0
261
- *
262
- * @global object $wpmem The WP_Members object.
263
- * @global string $wpmem_themsg The WP-Members message container.
264
- * @global object $post The WordPress post object.
265
- *
266
- * @param string $atts {
267
- * The shortcode attributes.
268
- *
269
- * @type string $page
270
- * @type string $redirect_to
271
- * @type string $register
272
- * }
273
- * @param string $content
274
- * @param string $tag
275
- * @return string $content
276
- */
277
- function wpmem_do_sc_pages( $atts, $content, $tag ) {
278
-
279
- $page = ( isset( $atts['page'] ) ) ? $atts['page'] : $tag;
280
- $redirect_to = ( isset( $atts['redirect_to'] ) ) ? $atts['redirect_to'] : null;
281
- $hide_register = ( isset( $atts['register'] ) && 'hide' == $atts['register'] ) ? true : false;
282
-
283
- global $wpmem, $wpmem_themsg, $post;
284
- include_once( WPMEM_PATH . 'inc/dialogs.php' );
285
-
286
- $content = '';
287
-
288
- // Deprecating members-area parameter to be replaced by user-profile.
289
- $page = ( $page == 'user-profile' ) ? 'members-area' : $page;
290
-
291
- if ( $page == 'members-area' || $page == 'register' ) {
292
-
293
- if ( $wpmem->regchk == "captcha" ) {
294
- global $wpmem_captcha_err;
295
- $wpmem_themsg = __( 'There was an error with the CAPTCHA form.' ) . '<br /><br />' . $wpmem_captcha_err;
296
- }
297
-
298
- if ( $wpmem->regchk == "loginfailed" ) {
299
- return wpmem_inc_loginfailed();
300
- }
301
-
302
- if ( ! is_user_logged_in() ) {
303
- if ( $wpmem->action == 'register' && ! $hide_register ) {
304
-
305
- switch( $wpmem->regchk ) {
306
-
307
- case "success":
308
- $content = wpmem_inc_regmessage( $wpmem->regchk,$wpmem_themsg );
309
- $content = $content . wpmem_inc_login();
310
- break;
311
-
312
- default:
313
- $content = wpmem_inc_regmessage( $wpmem->regchk,$wpmem_themsg );
314
- $content = $content . wpmem_inc_registration();
315
- break;
316
- }
317
-
318
- } elseif ( $wpmem->action == 'pwdreset' ) {
319
-
320
- $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
321
-
322
- } elseif( $wpmem->action == 'getusername' ) {
323
-
324
- $content = wpmem_page_forgot_username( $wpmem->regchk, $content );
325
-
326
- } else {
327
-
328
- $content = ( $page == 'members-area' ) ? $content . wpmem_inc_login( 'members' ) : $content;
329
- $content = ( ( $page == 'register' || $wpmem->show_reg[ $post->post_type ] != 0 ) && ! $hide_register ) ? $content . wpmem_inc_registration() : $content;
330
- }
331
-
332
- } elseif ( is_user_logged_in() && $page == 'members-area' ) {
333
-
334
- /**
335
- * Filter the default heading in User Profile edit mode.
336
- *
337
- * @since 2.7.5
338
- *
339
- * @param string The default edit mode heading.
340
- */
341
- $heading = apply_filters( 'wpmem_user_edit_heading', __( 'Edit Your Information', 'wp-members' ) );
342
-
343
- switch( $wpmem->action ) {
344
-
345
- case "edit":
346
- $content = $content . wpmem_inc_registration( 'edit', $heading );
347
- break;
348
-
349
- case "update":
350
-
351
- // Determine if there are any errors/empty fields.
352
-
353
- if ( $wpmem->regchk == "updaterr" || $wpmem->regchk == "email" ) {
354
-
355
- $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
356
- $content = $content . wpmem_inc_registration( 'edit', $heading );
357
-
358
- } else {
359
-
360
- //Case "editsuccess".
361
- $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
362
- $content = $content . wpmem_inc_memberlinks();
363
-
364
- }
365
- break;
366
-
367
- case "pwdchange":
368
-
369
- $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
370
- break;
371
-
372
- case "renew":
373
- $content = wpmem_renew();
374
- break;
375
-
376
- default:
377
- $content = wpmem_inc_memberlinks();
378
- break;
379
- }
380
-
381
- } elseif ( is_user_logged_in() && $page == 'register' ) {
382
-
383
- $content = $content . wpmem_inc_memberlinks( 'register' );
384
-
385
- }
386
-
387
- }
388
-
389
- if ( $page == 'login' ) {
390
- $content = ( $wpmem->regchk == "loginfailed" ) ? wpmem_inc_loginfailed() : $content;
391
- $content = ( ! is_user_logged_in() ) ? $content . wpmem_inc_login( 'login', $redirect_to ) : wpmem_inc_memberlinks( 'login' );
392
- }
393
-
394
- if ( $page == 'password' ) {
395
- $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
396
- }
397
-
398
- if ( $page == 'user-edit' ) {
399
- $content = wpmem_page_user_edit( $wpmem->regchk, $content );
400
- }
401
-
402
- return $content;
403
- } // End wpmem_do_sc_pages.
404
- endif;
405
-
406
  /**
407
  * User count shortcode [wpmem_show_count].
408
  *
@@ -452,18 +293,112 @@ function wpmem_sc_user_count( $atts, $content = null ) {
452
  * @since 3.1.0
453
  * @since 3.1.2 Added function arguments.
454
  *
455
- * @param array $atts {
 
 
 
456
  * The shortcode attributes.
457
  *
458
- * @type string $page
459
  * }
460
  * @param string $content
461
  * @param string $tag
462
  * @return string $content
463
  */
464
  function wpmem_sc_user_profile( $atts, $content, $tag ) {
465
- $atts['page'] = 'user-profile';
466
- $content = wpmem_do_sc_pages( $atts, $content, $tag );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  return $content;
468
  }
469
 
@@ -543,7 +478,7 @@ function wpmem_sc_fields( $atts, $content = null, $tag ) {
543
 
544
  global $wpmem;
545
  $fields = wpmem_fields();
546
- $field_type = ( isset( $fields[ $field ]['type'] ) ) ? $fields[ $field ]['type'] : 'native';
547
 
548
  $result = $user_info->{$field};
549
 
@@ -586,6 +521,11 @@ function wpmem_sc_fields( $atts, $content = null, $tag ) {
586
  }
587
  return do_shortcode( $result );
588
  }
 
 
 
 
 
589
 
590
  // Remove underscores from value if requested (default: on).
591
  if ( isset( $atts['underscores'] ) && 'off' == $atts['underscores'] && $user_info ) {
@@ -594,7 +534,7 @@ function wpmem_sc_fields( $atts, $content = null, $tag ) {
594
 
595
  $content = ( $content ) ? $result . $content : $result;
596
 
597
- return do_shortcode( htmlspecialchars( $content ) );
598
  }
599
  return;
600
  }
18
  * - wpmem_sc_forms
19
  * - wpmem_sc_logged_in
20
  * - wpmem_sc_logged_out
 
21
  * - wpmem_sc_user_count
22
  * - wpmem_sc_user_profile
23
  * - wpmem_sc_loginout
43
  function wpmem_sc_forms( $atts, $content = null, $tag = 'wpmem_form' ) {
44
 
45
  global $wpmem, $wpmem_themsg;
 
 
 
 
 
 
 
 
 
 
46
 
47
  // Defaults.
48
  $redirect_to = ( isset( $atts['redirect_to'] ) ) ? $atts['redirect_to'] : null;
193
  // If there is a "role" attribute and the user has a matching role.
194
  if ( isset( $atts['role'] ) ) {
195
  $roles = explode( ',', $atts['role'] );
196
+ if ( wpmem_user_has_role( $roles ) ) {
197
+ $do_return = true;
 
 
198
  }
199
  }
200
 
201
  // If there is a status attribute of "sub" and the user is logged in.
202
+ if ( ( isset( $atts['status'] ) ) && $atts['status'] == 'sub' ) {
203
  if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) {
204
  if ( ! wpmem_chk_exp() ) {
205
  $do_return = true;
210
  }
211
  }
212
 
213
+ // If there is a meta key attribute.
214
+ if ( isset( $atts['meta_key'] ) ) {
215
+ $value = ( isset( $atts['meta_value'] ) ) ? $atta['meta_value'] : false;
216
+ if ( wpmem_user_has_meta( $atts['meta_key'], $value ) ) {
217
+ $do_return = true;
218
+ }
219
+ }
220
+
221
+ // Prevents display if the current page is the user profile and an action is being handled.
222
+ if ( ( wpmem_current_url( true, false ) == wpmem_profile_url() ) && isset( $_GET['a'] ) ) {
223
  $do_return = false;
224
  }
225
 
244
  return ( ! is_user_logged_in() ) ? do_shortcode( $content ) : '';
245
  }
246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  /**
248
  * User count shortcode [wpmem_show_count].
249
  *
293
  * @since 3.1.0
294
  * @since 3.1.2 Added function arguments.
295
  *
296
+ * @global object $wpmem The WP_Members object.
297
+ * @global string $wpmem_themsg The WP-Members message container.
298
+ *
299
+ * @param string $atts {
300
  * The shortcode attributes.
301
  *
302
+ * @type string $redirect_to
303
  * }
304
  * @param string $content
305
  * @param string $tag
306
  * @return string $content
307
  */
308
  function wpmem_sc_user_profile( $atts, $content, $tag ) {
309
+
310
+ // @todo $redirect_to is not currently used in the user profile.
311
+ $redirect_to = ( isset( $atts['redirect_to'] ) ) ? $atts['redirect_to'] : null;
312
+ $hide_register = ( isset( $atts['register'] ) && 'hide' == $atts['register'] ) ? true : false;
313
+
314
+ global $wpmem, $wpmem_themsg;
315
+
316
+ $content = '';
317
+
318
+ if ( $wpmem->regchk == "captcha" ) {
319
+ global $wpmem_captcha_err;
320
+ $wpmem_themsg = __( 'There was an error with the CAPTCHA form.' ) . '<br /><br />' . $wpmem_captcha_err;
321
+ }
322
+
323
+ if ( $wpmem->regchk == "loginfailed" ) {
324
+ return wpmem_inc_loginfailed();
325
+ }
326
+
327
+ if ( is_user_logged_in() ) {
328
+
329
+ /**
330
+ * Filter the default heading in User Profile edit mode.
331
+ *
332
+ * @since 2.7.5
333
+ *
334
+ * @param string The default edit mode heading.
335
+ */
336
+ $heading = apply_filters( 'wpmem_user_edit_heading', $wpmem->get_text( 'profile_heading' ) );
337
+
338
+ switch( $wpmem->action ) {
339
+
340
+ case "edit":
341
+ $content = $content . wpmem_inc_registration( 'edit', $heading );
342
+ break;
343
+
344
+ case "update":
345
+ // Determine if there are any errors/empty fields.
346
+ if ( $wpmem->regchk == "updaterr" || $wpmem->regchk == "email" ) {
347
+ $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
348
+ $content = $content . wpmem_inc_registration( 'edit', $heading );
349
+ } else {
350
+ //Case "editsuccess".
351
+ $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
352
+ $content = $content . wpmem_inc_memberlinks();
353
+ }
354
+ break;
355
+
356
+ case "pwdchange":
357
+
358
+ $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
359
+ break;
360
+
361
+ case "renew":
362
+ $content = wpmem_renew();
363
+ break;
364
+
365
+ default:
366
+ $content = wpmem_inc_memberlinks();
367
+ break;
368
+ }
369
+
370
+ } else {
371
+
372
+ if ( $wpmem->action == 'register' && ! $hide_register ) {
373
+
374
+ switch( $wpmem->regchk ) {
375
+
376
+ case "success":
377
+ $content = wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
378
+ $content = $content . wpmem_inc_login();
379
+ break;
380
+
381
+ default:
382
+ $content = wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
383
+ $content = $content . wpmem_inc_registration();
384
+ break;
385
+ }
386
+
387
+ } elseif ( $wpmem->action == 'pwdreset' ) {
388
+
389
+ $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
390
+
391
+ } elseif( $wpmem->action == 'getusername' ) {
392
+
393
+ $content = wpmem_page_forgot_username( $wpmem->regchk, $content );
394
+
395
+ } else {
396
+
397
+ $content = $content . wpmem_inc_login( 'members' );
398
+ $content = ( ! $hide_register ) ? $content . wpmem_inc_registration() : $content;
399
+ }
400
+ }
401
+
402
  return $content;
403
  }
404
 
478
 
479
  global $wpmem;
480
  $fields = wpmem_fields();
481
+ $field_type = ( isset( $fields[ $field ]['type'] ) ) ? $fields[ $field ]['type'] : 'native'; // @todo Is this needed? It seems to set the type to "native" if not set.
482
 
483
  $result = $user_info->{$field};
484
 
521
  }
522
  return do_shortcode( $result );
523
  }
524
+
525
+ // Handle line breaks for textarea fields
526
+ if ( isset( $field_type ) && 'textarea' == $field_type ) {
527
+ $result = ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) ? $user_info->{$field} : nl2br( $user_info->{$field} );
528
+ }
529
 
530
  // Remove underscores from value if requested (default: on).
531
  if ( isset( $atts['underscores'] ) && 'off' == $atts['underscores'] && $user_info ) {
534
 
535
  $content = ( $content ) ? $result . $content : $result;
536
 
537
+ return do_shortcode( $content );
538
  }
539
  return;
540
  }
inc/users.php CHANGED
@@ -26,7 +26,7 @@ if ( ! function_exists( 'wpmem_user_profile' ) ):
26
  */
27
  function wpmem_user_profile() {
28
 
29
- global $wpmem, $user_id;
30
  /**
31
  * Filter the heading for the user profile additional fields.
32
  *
@@ -69,13 +69,17 @@ function wpmem_user_profile() {
69
  $attachment_url = wp_get_attachment_url( $val );
70
  $empty_file = '<span class="description">' . __( 'None' ) . '</span>';
71
  if ( 'file' == $field['type'] ) {
72
- $input = ( 0 < $attachment_url ) ? '<a href="' . $attachment_url . '">' . $attachment_url . '</a>' : $empty_file;
73
  } else {
74
- $input = ( 0 < $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file;
75
  }
76
- // @todo - come up with a way to handle file updates - user profile form does not support multitype
77
- //$show_field.= '<br /><span class="description">' . __( 'Update this file:' ) . '</span><br />';
78
- //$show_field.= wpmem_create_formfield( $meta . '_update_file', $field['type'], $val, $valtochk );
 
 
 
 
79
  } else {
80
  if ( $meta == 'tos' && $val == 'agree' ) {
81
  $input = wpmem_create_formfield( $meta, 'hidden', $val );
@@ -202,6 +206,30 @@ function wpmem_profile_update() {
202
  }
203
  }
204
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
 
207
  // End of file.
26
  */
27
  function wpmem_user_profile() {
28
 
29
+ global $wpmem, $user_id, $current_screen;
30
  /**
31
  * Filter the heading for the user profile additional fields.
32
  *
69
  $attachment_url = wp_get_attachment_url( $val );
70
  $empty_file = '<span class="description">' . __( 'None' ) . '</span>';
71
  if ( 'file' == $field['type'] ) {
72
+ $input = ( $attachment_url ) ? '<a href="' . $attachment_url . '">' . $attachment_url . '</a>' : $empty_file;
73
  } else {
74
+ $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file;
75
  }
76
+ $input.= '<br />' . $wpmem->get_text( 'profile_upload' ) . '<br />';
77
+ $input.= wpmem_form_field( array(
78
+ 'name' => $meta,
79
+ 'type' => $field['type'],
80
+ 'value' => $val,
81
+ 'compare' => $valtochk,
82
+ ) );
83
  } else {
84
  if ( $meta == 'tos' && $val == 'agree' ) {
85
  $input = wpmem_create_formfield( $meta, 'hidden', $val );
206
  }
207
  }
208
  }
209
+
210
+ if ( ! empty( $_FILES ) ) {
211
+ $wpmem->user->upload_user_files( $user_id, $wpmem_fields );
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Sets user profile update to multipart form data.
217
+ *
218
+ * If the fields array has a file or image field, this will echo the
219
+ * necessary "multipart/form-data" enctype for the form tag.
220
+ *
221
+ * @since 3.1.8
222
+ */
223
+ function wpmem_user_profile_multipart() {
224
+ global $wpmem;
225
+ $has_file = false;
226
+ foreach ( wpmem_fields() as $field ) {
227
+ if ( $field['type'] == 'file' || $field['type'] == 'image' ) {
228
+ $has_file = true;
229
+ break;
230
+ }
231
+ }
232
+ echo ( $has_file ) ? " enctype=\"multipart/form-data\"" : '';
233
  }
234
 
235
  // End of file.
inc/wp-registration.php CHANGED
@@ -27,22 +27,27 @@
27
  * @since 2.8.7
28
  * @since 3.1.1 Updated to support new (3.1.0) field types.
29
  * @since 3.1.6 Updated to support new fields array. Added WC classes.
 
30
  */
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;
38
- if ( function_exists( 'is_account_page' ) ) {
39
- $is_woo = ( is_account_page() ) ? true : $is_woo;
 
 
 
 
40
  }
41
 
42
  if ( isset( $wpmem_fields ) && is_array( $wpmem_fields ) ) {
43
  foreach ( $wpmem_fields as $meta_key => $field ) {
44
 
45
- $req = ( $field['required'] ) ? ' <span class="req">' . __( '(required)' ) . '</span>' : '';
46
 
47
  // File fields not yet supported for this form.
48
  if ( $field['register'] && $meta_key != 'user_email' && $field['type'] != 'file' && $field['type'] != 'image' ) {
27
  * @since 2.8.7
28
  * @since 3.1.1 Updated to support new (3.1.0) field types.
29
  * @since 3.1.6 Updated to support new fields array. Added WC classes.
30
+ * @since 3.1.8 Added $process parameter.
31
  */
32
+ function wpmem_do_wp_register_form( $process = 'wp' ) {
33
 
34
  global $wpmem;
35
+ $wpmem_fields = wpmem_fields( $process );
36
 
37
  // Check if this is WooCommerce account page.
38
  $is_woo = false;
39
+ if ( 'woo' == $process ) {
40
+ $is_woo = true;
41
+ } else {
42
+ if ( function_exists( 'is_account_page' ) ) {
43
+ $is_woo = ( is_account_page() ) ? true : $is_woo;
44
+ }
45
  }
46
 
47
  if ( isset( $wpmem_fields ) && is_array( $wpmem_fields ) ) {
48
  foreach ( $wpmem_fields as $meta_key => $field ) {
49
 
50
+ $req = ( $field['required'] ) ? ( ( $is_woo ) ? ' <span class="required">*</span>' : ' <span class="req">' . __( '(required)' ) . '</span>' ) : '';
51
 
52
  // File fields not yet supported for this form.
53
  if ( $field['register'] && $meta_key != 'user_email' && $field['type'] != 'file' && $field['type'] != 'image' ) {
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.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,7 +112,8 @@ Premium priority support is available at the plugin's site [RocketGeek.com](http
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,6 +136,32 @@ WP-Members 3.1.7 is a major update. There are no database changes (rollback is p
135
 
136
  == Changelog ==
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  = 3.1.7 =
139
 
140
  * API updates: added wpmem_is_user_activated().
@@ -163,252 +190,4 @@ WP-Members 3.1.7 is a major update. There are no database changes (rollback is p
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
-
170
- * Fixed [wpmem_field] display handling for multiple select and multiple checkbox field types.
171
- * Updates to always load fields from wpmem_fields() API function.
172
- * Updates to begin to utilize new fields settings array. Fields setting is still store in the same array format as before. However, it is loaded into the new settings format. Current object class keeps numeric keys in place for legacy purposes.
173
- * Updates to dropdown handling on main options tab to display proper preselected value when site is using ssl (https://) and no value is selected.
174
- * Added wpmem_loginout() API function, changed [wpmem_loginout] shortcode to use API function.
175
- * Added wpmem_array_insert() API function, allows for inserting array elements at any point in an array.
176
- * Added wp_destroy_current_session() to logout function.
177
- * Added WooCommerce support in native WP registration functions. Began adding WooCommerce classes to registration form elements.
178
- * Added to wpmem_user_has_role() function to check for a single role or if the user has a role that is in an array of roles.
179
- * Added wpmem_shortcodes_loaded, wpmem_hooks_loaded, and wpmem_dropins_loaded to fire after.
180
- * Added text input to set a default 'read more' link for auto excerpt.
181
- * Fixed issue with auto excerpt where an excerpt shorter than the excerpt setting would not display the more link.
182
- * Preliminary updates to include placeholder support in fields (this will be an option in a future release).
183
- * Localization fix of untranslated strings.
184
- * Wrap "Remember Me" checkbox label with label tag in login form.
185
- * Moved remaining initialization functions to class constructor.
186
- * Moved wpmem_load_shortcodes, wpmem_load_hooks, and wpmem_load_dropins to fire before.
187
- * reCAPTCHA version 1 is no longer supported by Google. It is now deprecated in the plugin. If you have reCAPTCHA v1 selected, it will remain so. But once this is changed to a different CAPTCHA setting or if this is a new install, reCAPTCHA version 1 will no longer be available as a selection.
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
-
198
- * Addressed some security issues to prevent XSS vulnerabilities.
199
- * Updated [wpmem_show_count] shortcode to include count of total blog users and users by role. See: http://rkt.bz/xC
200
- * Updated [wpmem_field] shortcode to accept [wpmem_field meta_key] instead of [wpmem_field field="meta_key"] (although the latter will still work). See http://rkt.bz/ae
201
- * Updated [wpmem_loginout] shortcode with some improvements to function code and link text attributes. See: http://rkt.bz/29
202
- * Updated auto excerpt for improved functionality, uses wp_trim_words(), deprecated add_ellipsis, strip_tags, close_tags, parse_shortcodes, strip_shortcodes for filter (these were never documented so it is unlikely that anyone uses them).
203
- * Updated hidden field type, now allows adding hidden fields to the registration form.
204
- * Compartmentalized installation of initial settings.
205
- * Field loader now validates settings, if none exist due to install error it will run the default fields install.
206
- * Removed dialog setting downgrade on deactivation. Need to re-evaluate necessity of downgrading.
207
- * Fixed issue with slash handling in Emails tab.
208
- * Updated [wp-members] deprecated shortcode notice to include post/page information on where the shortcode is being used.
209
-
210
- = 3.1.4 =
211
-
212
- * Change to the way the PayPal extension is integrated with the main plugin. This allows for some necessary filename changes in the extension.
213
- * Added checks for PayPal extension function calls within the main plugin to avoid possible errors if it is deactivated.
214
- * New wpmem_is_tab() API function checks the current tab in the plugin's admin panel.
215
- * New wpmem_is_reg_page() API function checks if the page the user registered on is the registration page.
216
- * New wpmem_load_dropins() API function runs dropin load function.
217
- * Documentation updates, cleaned up and addressed several @todo tags.
218
- * Updated [wpmem_field] shortcode to display display values instead of stored values for select (dropdown), multiple select, multiple checkbox, and radio group field types.
219
- * Fixed bug in admin js file introduced when forgot username shortcode was added.
220
- * Updates to reCAPTCHA2. Trims keys on save to avoid possible copy/paste whitespace issues, displays API error code(s) if WP_DEBUG is turned on, change use of file_get_contents() to wp_remote_fopen() for broader acceptable use.
221
-
222
- = 3.1.3 =
223
-
224
- * Fixed issue with display of [wp-members] field tag. Note: although this tag should remain operable, the tag is officially obsolete since 2.9.8 and should be used as [wpmem_field].
225
- * Fixed issue with calling PayPal extension functions if settings are enabled but the extension is disabled.
226
- * Updated some admin-side strings for translation.
227
- * Updated wpmem_redirect_to_login() to __not__ check for wpmem_is_blocked(). Handling that outside the function will expand its usability.
228
- * Updated row_after logic in login form function so that it can be used for adding tags at the end of a row w/o adding a tag at the beginning.
229
- * Updated widget to check for wpmem_do_sidebar() instead of obsolete wpmem() function.
230
- * Updated email shortcodes used in new install.
231
- * Added new utility function wpmem_get() for checking posted variables and query strings with isset() and setting a default value.
232
- * Added a nonce to register redirect by shortcode parameter. This will lead to being able to display a success message on the redirected page.
233
- * Added redirect_to argument in wpmem_redirect_to_login().
234
- * Added generic registration error message.
235
- * Added [wpmem_form forgot_username] shortcode for displaying the forgot username form.
236
-
237
- = 3.1.2 =
238
-
239
- * Minimum WordPress version increased to 3.6.
240
- * Added user counts to user screen links (set as transient).
241
- * Added redirect_to parameter to wpmem_login_url().
242
- * Added action parameter to wpmem_profile_url().
243
- * Added echo argument to wpmem_gettext().
244
- * Added api function wpmem_user_pages() to return an array of the login, register, and profile page urls.
245
- * Added shortcode [wpmem_tos] for Terms of Service page url (replaces [wp-members page=tos url=http://mysite.com/path/to/tos/]).
246
- * Added wpmem_write_log() function for writing notices to the WP error log.
247
- * Added hide registration form parameter to wpmem_profile shortcode: [wpmem_profile register=hide].
248
- * Added $defaults to wpmem_sidebar_status_args. Now can pass $user_login to be used in filters.
249
- * Moved wpmem_login_status() to api.php.
250
- * Deprecated [wp-members] shortcode, all other shortcodes no longer rely on wpmem_shortcode().
251
- * Fixed issue with pre-selected dropdown values to not select empty (separator) rows.
252
- * Fixed field and custom shortcodes in email not being parsed.
253
-
254
- = 3.1.1 =
255
-
256
- * Added downgrade function (currently runs on deactivation) to allow for version rollbacks.
257
- * Added new dialogs functions to admin api, allows for custom dialogs to be added.
258
- * Added $user_id and $row to wpmem_admin_profile_field and wpmem_user_profile_field filters.
259
- * Added new api class and api functions.
260
- * Added [wpmem_loginout] shortcode.
261
- * Added support for new field types to native registration and users > add new (except file/image fields).
262
- * Updated users > add new so that user can be activated when added.
263
- * Updated [wpmem_logged_in] shortcode so that content is not shown on on a user profile page action.
264
- * Updated email settings to only save new from/name if changed.
265
- * Updated admin warning messges.
266
- * Updated multiselect and multicheckbox fields to allow user selected delimiter (defaults to pipe "|").
267
- * Fixes issue with profile update when file/image field is required.
268
- * Fixes image field edit in fields tab to include file type.
269
- * Fixes attribution setting for 3.0 settings array.
270
- * Fixes for PHP7.
271
-
272
- = 3.1.0 =
273
-
274
- This package contains several fixes, some new filters, new field types and other functional improvements.
275
-
276
- * Some general code cleanup, reviewing inline documentation and comments.
277
- * Fixed issue for sidebar with redirect_to parameter set in widget settings.
278
- * Fixed issue for custom error messages and email comparison error for profile update (so that errors show in form update state and not on links page).
279
- * Fixed main options tab where checkbox may not display correct setting if unchecked.
280
- * Fixed translation issue for required field error where all of the message except the field name was translated.
281
- * Fixed issue for register shortcode page where if a user has registered, and is logging in but the login fails, display the login error message.
282
- * Fixed register shortcode redirect parameter.
283
- * Fixed confirm_password to bypass sanitize_text_field (which breaks password comparison if certain characters are used).
284
- * Added logic so that user_pages are not blocked (login, register, user_profile).
285
- * Added after_wrapper array value for wpmem_{$page}_links_args filters
286
- * Added a new admin api class, utilities object class, and forms object class.
287
- * Added user facing strings as an array in the main $wpmem object class.
288
- * Added wpmem_default_text_strings filter for user facing text strings.
289
- * Added new wpmem_sidebar_status_args filter hook.
290
- * Added new container in main object for email from and from name settings.
291
- * Added file upload functions.
292
- * Added new field types: multiple checkbox, multiple select, radio, file, image, email, url.
293
- * Added "values" key to the register form rows array to hold possible values (i.e. select, multiple select, multiple checkbox, and radio group) and the actual value to be in the "value" key.
294
- * Added the ability for dropdown/select fields to have a default value other than the first value.
295
- * Added filter wpmem_user_upload_dir for filtering the location of user uploaded files.
296
- * Added wpmem_register_form_rows_admin and wpmem_register_form_rows_profile filter hooks.
297
- * Deprecated use of wpmem_chk_qstr() function, use add_query_arg() instead.
298
- * Deprecated use of get_currentuserinfo() (deprecated in WP 4.5), use wp_get_current_user() instead.
299
- * Email function updates, added 'footer' as an array value in the main wpmem_email_filter filter.
300
- * Changed install to set email/confirm_email and user_url as HTML5 field types "email" and "url" (now supported).
301
- * Changed get_action call from init action to template_redirect action.
302
- * Changed username in register form from log to user_login to match wp native registration form.
303
- * Changed [wp-members page="user-profile"] shortcode to [wpmem_profile] (old shortcode will still work).
304
- * Removed redirect parameter from register shortcode in shortcode menu.
305
- * Removed kubrick stylesheet from selector (still packaged with download, shows as custom url if used).
306
- * Changed all _update_ functions in install package to _upgrade_.
307
- * Fixes an issue with PayPal extension where users may be set to pending if moderated registration is enabled after the user already has an expiration date.
308
- * Update wpmem_do_sidebar to use use add_query_arg() if on a search query.
309
-
310
- = 3.0.9 =
311
-
312
- * Added Custom Post Type support.
313
- * Added wpmem_member_links_args and wpmem_register_links_args filters.
314
- * Added $link parameter to wpmem_forgot_link_str and wpmem_reg_link_str filters (gives just the link as an available parameter).
315
- * Added new wpmem_sb_reg_link_str and wpmem_sb_forgot_link_str filters (same format as above).
316
- * Added [email] and [user-profile] shortcodes to the new user registration email.
317
- * Added label_text key to wpmem_register_form_rows filter.
318
- * Added new auto excerpt settings, can now be set by post type.
319
- * Added new auto excerpt features including new wpmem_auto_excerpt_args filter.
320
- * Added forgot username retrieveal link (included on forgot password reset form).
321
- * Added wpmem_username_link and wpmem_username_link_str for filtering forgot username retrieval link.
322
- * Added new upgrade process to WP_Members object class.
323
- * Fixed handling of post bulk actions to keep current screen (if one is used).
324
- * Fixed handling of updates to the user pages in the options tab.
325
- * Fixed handling of empty post object in is_blocked() function.
326
- * Improved email functions to eliminate get_user_meta() calls when not needed.
327
-
328
- = 3.0.8 =
329
-
330
- * Added process for forgotten username retrieval.
331
- * Removed last remaining instances of extract function.
332
- * Updated settings for special pages (login|register|user-profile) to store only the numeric primary key ID. This will eliminate the need to update these settings if the site is moved (from a dev to live site, for example). Legacy full URL settings will still be compatible without needing to be updated, but will be automatically updated when main options are saved.
333
-
334
- = 3.0.7 =
335
-
336
- * Fix for use of display_name on profile update.
337
- * Fix for newer installs (post WP 4.0) where WPLANG is not defined and reCAPTCHA is used.
338
- * Fix in wpmem_form shortcode to skp if no additional tag exists.
339
- * Fix to plugin_basename.
340
- * Changes in core to use fields from WP_Members class (preparing for new form field process).
341
- * Reviews and updates to code standards and inline documentation.
342
- * Fix for password reset (typo in object name checking for moderated registration)
343
- * Fix for PayPal extension (http://rkt.bz/r3); added logic to avoid errors if the PayPal extension is disabled but the main option setting remained turned on.
344
-
345
- = 3.0.6 =
346
-
347
- * Updates to localization function - documented plugin_locale filter, wpmem_localization_file filter, and improved load_textdomain logic.
348
- * Added /lang domain path to plugin header.
349
- * Fixed a bug in the user export function that broke CSV columns when moderated registration was turned on.
350
- * Improved current page retrieval in wpmem_redirect_to_login() function.
351
- * Fixed admin enqueued scripts (post/page screen hook did not load from new location).
352
-
353
- = 3.0.5 =
354
-
355
- * Updated wpmem_pwd_change and wpmem_pwd_reset action hooks to include password as a parameter.
356
- * Stylesheet updates for 2015, 2014, and generic (both float and no float).
357
- * Fix to TinyMCE shortcode button, should now load button on new post/page editor.
358
- * Added [WP-Members] to the TinyMCE shortcode button for clarity as to what it is.
359
- * Moved admin js and css files to /admin/js/ and /admin/css/
360
- * Moved admin class files to /admin/includes/
361
- * Updated and verified all directories contain an index.php file to prevent directory browsing.
362
-
363
- = 3.0.4 =
364
-
365
- * Reintroduced the global action variable $wpmem_a for backward compatibility with certain add-ons, most notably the WP-Members MailChimp extension ( see http://rkt.bz/3b ). Users of this extension should upgrade. This variable had been replaced with the new WP-Members object class introduced in 3.0. However, users of older extensions and those that may have customziations with logic may be using this variable, so rather than force updating and upgrading, it is being added back in.
366
- * Change to the priority of functions hooked to the the_content filter. Lowering the priority should better integrate the plugin with various builder plugins and other processes that currently filter the_content after WP-Members since the content will now be filtered later in the process. This also should improve situations where in the past the on-the-fly texturization shortcode for the WP-Members forms might remain unparsed.
367
-
368
- = 3.0.3 =
369
-
370
- * Bug fix recaptcha v2 decode json response on validation.
371
- * Bug fix typo in $wpmem object name in admin/user-profile.php.
372
- * Bug fix message string variable in wpmem_msg_dialog_arr filter.
373
- * Fix register form shortcode redirect_to parameter.
374
- * Admin forms now use submit_button() function to generate submit button.
375
- * Changed localization to load on init action which will allow for more flexibility with filtering custom language files.
376
- * Added wpmem_localization_file and wpmem_localization_dir filters.
377
- * Localization checks for file in /wp-content/ language directory first, then loads plugin default.
378
-
379
- = 3.0.2 =
380
-
381
- * Added reCAPTCHA version 2 as an option. v1 will remain available for now, to be fully deprecated later.
382
- * Fixed widget to use __construct for WP 4.3 compatibility.
383
- * Added error checking for WP reserved names when adding new custom fields.
384
- * Added wpmem_wp_reserved_terms filter for overriding reserved terms list.
385
- * Added trim whitespace to password reset and password change form validation.
386
-
387
- = 3.0.1 =
388
-
389
- * Fixed use of wp_signon() for ssl.
390
- * Fixed [wpmem_msurl] email shortcode.
391
- * Fixed admin js and css load (removed unnecessary slash).
392
- * Fixed autoexcerpt to use setting from object and not wpmemembers_autoex option.
393
- * Added filter to remove comments array if content is blocked.
394
-
395
- = 3.0.0 =
396
-
397
- This release makes significant changes to the plugin's main options in the way they are stored. While care has been taken to make sure that you can roll back to a previous version, you may need to resave settings in the plugin's main options tab when attempting to roll back. It is advised that you test this update prior upgrading an existing install on a production site.
398
-
399
- If you have any custom functions hooked to filters and actions that call any file includes directly from the plugin, please note that several file names have changed.
400
-
401
- * New settings and new plugin class WP_Members.
402
- * New settings now natively support Custom Post Types, both setting defaults and individual post blocking.
403
- * Settings constants removed in favor of using the $wpmem object class.
404
- * Added new|edit toggle to wpmem-register_data filter hook.
405
- * wpmem_settings_loaded action added.
406
- * Securify comments changed to use comments_open instead of comments_template (with a blank template).
407
- * New wpmem_securify_comments filter hook to customize whether comments load or not.
408
- * Registration clear form button defaults to false.
409
- * Removed wp_set_auth_cookie from login function; it is already done as part of wp_signon.
410
- * Post meta box title filter is now for all post types wpmem_admin_{post type}_meta_title.
411
- * New filter for Really Simple Captcha folder location: wpmem_rs_captcha_folder.
412
- * New shortcodes [wpmem_form] added.
413
- * Shortcode dropdown selector added to tinymce toolbar in Post/Page editor.
414
- * Added redirect_to as a function argument if calling wpmem_logout() directly.
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
6
+ Stable tag: 3.1.8.1
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.8 is a major update. There are no database changes (rollback is possible). See changelog for important details. Minimum WP version is 3.6.
116
+ WP-Members 3.1.8.1 corrects a minor issue for text area fields. See changelog.
117
 
118
  == Screenshots ==
119
 
136
 
137
  == Changelog ==
138
 
139
+ = 3.1.8.1 =
140
+
141
+ * Corrects an issue with user profile display/update of textarea fields that are not the WP default bio field.
142
+ * Added display=raw attribute handling to textarea fields to allow display without converting line breaks to HTML br tags.
143
+ * Fixes issue with User Profile form heading not using the get_text() value.
144
+ * Improves logic for displaying register link in login form if login page is not set.
145
+
146
+ = 3.1.8 =
147
+
148
+ * Added new native registration handling to accommodate WooCommerce 3.0.
149
+ * Added support for user file upload on admin/dashboard profile.
150
+ * Added meta_key/meta_value attribute to [wpmem_logged_in] shortcode.
151
+ * Added wpmem_user_has_meta() API function.
152
+ * Updated post editor shortcode button javascript to include new(er) shortcodes.
153
+ * Fixed WP-Members user profile shortcode to only display logged in content (by shortcode) if the wpmem_a 'action' is not set (i.e. logged in content only displays if page is in "member links" state).
154
+ * Fixed register link in login form to prevent link from displaying if login form is displayed along with the registration form (standard configuration).
155
+ * Improved multisite support, including revisions to load all admin dependencies for administrator role, not just super admin. Dependency load role requirement is filterable.
156
+ * Improved line break stripping process in form builder to allow for line breaks in textarea fields.
157
+ * Improved field shortcode for textarea fields to display line breaks.
158
+ * Deprecated old wpmem_do_sc_pages() function, updated wpmem_sc_user_profile().
159
+ * Removed $_SERVER['REQUEST_URI'] from all admin tab form action attributes. Replaced with new wpmem_admin_form_post_url() API function.
160
+ * Fields Tab: ground-up rebuild to utilize WP_List_Table and jquery sorting UI.
161
+ * Fields Tab: improved field add/edit screen: return link at bottom of page, display current field upon successful form submission, success message include return link.
162
+ * Fields Tab: added support for HTML5 field types: number, date.
163
+ * Fields Tab: added support for HTML5 field attributes: placeholder, pattern (regex), title, min, max.
164
+
165
  = 3.1.7 =
166
 
167
  * API updates: added wpmem_is_user_activated().
190
  * Deprecated wpmem_register_fields_arr filter (Use wpmem_fields instead).
191
  * Removing the wpautop() function is now optional rather than default.
192
  * Fixed load fields error checking, install function now correctly returns defaults.
193
+ * Changed password reset and password change to use wp_set_password() for improved performance with caching.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.7
7
  Author: Chad Butler
8
  Author URI: http://butlerblog.com/
9
  Text Domain: wp-members
@@ -62,7 +62,7 @@ License: GPLv2
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__ ) );
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.8.1
7
  Author: Chad Butler
8
  Author URI: http://butlerblog.com/
9
  Text Domain: wp-members
62
 
63
 
64
  // Initialize constants.
65
+ define( 'WPMEM_VERSION', '3.1.8.1' );
66
  define( 'WPMEM_DEBUG', false );
67
  define( 'WPMEM_DIR', plugin_dir_url ( __FILE__ ) );
68
  define( 'WPMEM_PATH', plugin_dir_path( __FILE__ ) );