WP-Members Membership Plugin - Version 3.0.8

Version Description

  • Added process for forgotten username retrieval.
  • Removed last remaining instances of extract function.
  • 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.
Download this release

Release Info

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

Code changes from version 3.0.7 to 3.0.8

admin/tab-captcha.php CHANGED
@@ -120,27 +120,27 @@ function wpmem_a_build_captcha_options() {
120
  'img_type' => 'png',
121
  );
122
 
123
- $args = ( is_array( $wpmem_captcha['really_simple'] ) ) ? $wpmem_captcha['really_simple'] : array();
124
 
125
- extract( wp_parse_args( $args, $defaults ) );
126
 
127
  // Explode colors.
128
- $font_color = explode( ',', $font_color );
129
- $bg_color = explode( ',', $bg_color );
130
 
131
  $show_update_button = true;
132
  if ( is_plugin_active( 'really-simple-captcha/really-simple-captcha.php' ) ) { ?>
133
  <tr>
134
  <th scope="row"><?php _e( 'Characters for image', 'wp-members' ); ?></th>
135
- <td><input name="characters" type="text" size="34" value="<?php echo $characters; ?>" /></td>
136
  </tr>
137
  <tr>
138
  <th scope="row"><?php _e( 'Number of characters', 'wp-members' ); ?></th>
139
- <td><input name="num_char" type="text" size="2" value="<?php echo $num_char; ?>" /></td>
140
  </tr>
141
  <tr>
142
  <th scope="row"><?php _e( 'Image dimensions', 'wp-members' ); ?></th>
143
- <td><?php _e( 'Width' ); ?> <input name="dim_w" type="text" size="2" value="<?php echo $dim_w; ?>" /> <?php _e( 'Height' ); ?> <input name="dim_h" type="text" size="2" value="<?php echo $dim_h; ?>" /></td>
144
  </tr>
145
  <tr>
146
  <th scope="row"><?php _e( 'Font color of characters', 'wp-members' ); ?></th>
@@ -152,18 +152,18 @@ function wpmem_a_build_captcha_options() {
152
  </tr>
153
  <tr>
154
  <th scope="row"><?php _e( 'Font size', 'wp-members' ); ?></th>
155
- <td><input name="font_size" type="text" value="<?php echo $font_size; ?>" /></td>
156
  </tr>
157
  <tr>
158
  <th scope="row"><?php _e( 'Width between characters', 'wp-members' ); ?></th>
159
- <td><input name="kerning" type="text" value="<?php echo $kerning; ?>" /></td>
160
  </tr>
161
  <tr>
162
  <th scope="row"><?php _e( 'Image type', 'wp-members' ); ?></th>
163
  <td><select name="img_type">
164
- <option<?php echo ( $img_type == 'png' ) ? ' selected' : ''; ?>>png</option>
165
- <option<?php echo ( $img_type == 'gif' ) ? ' selected' : ''; ?>>gif</option>
166
- <option<?php echo ( $img_type == 'jpg' ) ? ' selected' : ''; ?>>jpg</option>
167
  </select>
168
  </td>
169
  </tr><?php
120
  'img_type' => 'png',
121
  );
122
 
123
+ $args = ( isset( $wpmem_captcha['really_simple'] ) && is_array( $wpmem_captcha['really_simple'] ) ) ? $wpmem_captcha['really_simple'] : array();
124
 
125
+ $args = wp_parse_args( $args, $defaults );
126
 
127
  // Explode colors.
128
+ $font_color = explode( ',', $args['font_color'] );
129
+ $bg_color = explode( ',', $args['bg_color'] );
130
 
131
  $show_update_button = true;
132
  if ( is_plugin_active( 'really-simple-captcha/really-simple-captcha.php' ) ) { ?>
133
  <tr>
134
  <th scope="row"><?php _e( 'Characters for image', 'wp-members' ); ?></th>
135
+ <td><input name="characters" type="text" size="34" value="<?php echo $args['characters']; ?>" /></td>
136
  </tr>
137
  <tr>
138
  <th scope="row"><?php _e( 'Number of characters', 'wp-members' ); ?></th>
139
+ <td><input name="num_char" type="text" size="2" value="<?php echo $args['num_char']; ?>" /></td>
140
  </tr>
141
  <tr>
142
  <th scope="row"><?php _e( 'Image dimensions', 'wp-members' ); ?></th>
143
+ <td><?php _e( 'Width' ); ?> <input name="dim_w" type="text" size="2" value="<?php echo $args['dim_w']; ?>" /> <?php _e( 'Height' ); ?> <input name="dim_h" type="text" size="2" value="<?php echo $args['dim_h']; ?>" /></td>
144
  </tr>
145
  <tr>
146
  <th scope="row"><?php _e( 'Font color of characters', 'wp-members' ); ?></th>
152
  </tr>
153
  <tr>
154
  <th scope="row"><?php _e( 'Font size', 'wp-members' ); ?></th>
155
+ <td><input name="font_size" type="text" value="<?php echo $args['font_size']; ?>" /></td>
156
  </tr>
157
  <tr>
158
  <th scope="row"><?php _e( 'Width between characters', 'wp-members' ); ?></th>
159
+ <td><input name="kerning" type="text" value="<?php echo $args['kerning']; ?>" /></td>
160
  </tr>
161
  <tr>
162
  <th scope="row"><?php _e( 'Image type', 'wp-members' ); ?></th>
163
  <td><select name="img_type">
164
+ <option<?php echo ( $args['img_type'] == 'png' ) ? ' selected' : ''; ?>>png</option>
165
+ <option<?php echo ( $args['img_type'] == 'gif' ) ? ' selected' : ''; ?>>gif</option>
166
+ <option<?php echo ( $args['img_type'] == 'jpg' ) ? ' selected' : ''; ?>>jpg</option>
167
  </select>
168
  </td>
169
  </tr><?php
admin/tab-emails.php CHANGED
@@ -43,6 +43,10 @@ function wpmem_a_build_emails() {
43
  $wpmem_email_title_arr,
44
  array( __( "Password Reset", 'wp-members' ), 'wpmembers_email_repass' )
45
  );
 
 
 
 
46
  if ( $wpmem->notify == 1 ) {
47
  array_push(
48
  $wpmem_email_title_arr,
@@ -147,6 +151,7 @@ function wpmem_update_emails() {
147
  // Update the various emails being used.
148
  ( $wpmem->mod_reg == 0 ) ? $arr = array( 'wpmembers_email_newreg' ) : $arr = array( 'wpmembers_email_newmod', 'wpmembers_email_appmod' );
149
  array_push( $arr, 'wpmembers_email_repass' );
 
150
  ( $wpmem->notify == 1 ) ? array_push( $arr, 'wpmembers_email_notify' ) : false;
151
  array_push( $arr, 'wpmembers_email_footer' );
152
 
43
  $wpmem_email_title_arr,
44
  array( __( "Password Reset", 'wp-members' ), 'wpmembers_email_repass' )
45
  );
46
+ array_push(
47
+ $wpmem_email_title_arr,
48
+ array( __( "Retrieve Username", 'wp-members' ), 'wpmembers_email_getuser' )
49
+ );
50
  if ( $wpmem->notify == 1 ) {
51
  array_push(
52
  $wpmem_email_title_arr,
151
  // Update the various emails being used.
152
  ( $wpmem->mod_reg == 0 ) ? $arr = array( 'wpmembers_email_newreg' ) : $arr = array( 'wpmembers_email_newmod', 'wpmembers_email_appmod' );
153
  array_push( $arr, 'wpmembers_email_repass' );
154
+ array_push( $arr, 'wpmembers_email_getuser' );
155
  ( $wpmem->notify == 1 ) ? array_push( $arr, 'wpmembers_email_notify' ) : false;
156
  array_push( $arr, 'wpmembers_email_footer' );
157
 
admin/tab-options.php CHANGED
@@ -402,7 +402,7 @@ function wpmem_admin_page_list( $val, $show_custom_url = true ) {
402
 
403
  foreach ( $pages as $page ) {
404
  $selected = ( get_page_link( $page->ID ) == $val ) ? true : $selected;
405
- $option = '<option value="' . get_page_link( $page->ID ) . '"' . wpmem_selected( get_page_link( $page->ID ), $val, 'select' ) . '>';
406
  $option .= $page->post_title;
407
  $option .= '</option>';
408
  echo $option;
402
 
403
  foreach ( $pages as $page ) {
404
  $selected = ( get_page_link( $page->ID ) == $val ) ? true : $selected;
405
+ $option = '<option value="' . $page->ID . '"' . wpmem_selected( get_page_link( $page->ID ), $val, 'select' ) . '>';
406
  $option .= $page->post_title;
407
  $option .= '</option>';
408
  echo $option;
admin/user-export.php CHANGED
@@ -38,7 +38,7 @@ function wpmem_export_users( $args, $users = null ) {
38
  'exclude_fields' => array( 'password', 'confirm_password', 'confirm_email' ),
39
  );
40
 
41
- // Merge $args with defaults and extract.
42
  /**
43
  * Filter the default export arguments.
44
  *
@@ -46,18 +46,18 @@ function wpmem_export_users( $args, $users = null ) {
46
  *
47
  * @param array $args An array of arguments to merge with defaults. Default null.
48
  */
49
- extract( wp_parse_args( apply_filters( 'wpmem_export_args', $args ), $defaults ) );
50
 
51
  // Output needs to be buffered, start the buffer.
52
  ob_start();
53
 
54
  // If exporting all, get all of the users.
55
- $users = ( $export == 'all' ) ? get_users( array( 'fields' => 'ID' ) ) : $users;
56
 
57
  // Generate headers and a filename based on date of export.
58
  header( "Content-Description: File Transfer" );
59
  header( "Content-type: application/octet-stream" );
60
- header( "Content-Disposition: attachment; filename=" . $filename );
61
  header( "Content-Type: text/csv; charset=" . get_option( 'blog_charset' ), true );
62
  echo "\xEF\xBB\xBF"; // UTF-8 BOM
63
 
@@ -68,7 +68,7 @@ function wpmem_export_users( $args, $users = null ) {
68
  $hrow = "User ID,Username,";
69
 
70
  foreach ( $wpmem_fields as $meta ) {
71
- if ( ! in_array( $meta[2], $exclude_fields ) ) {
72
  $hrow.= $meta[1] . ",";
73
  }
74
  }
@@ -99,7 +99,7 @@ function wpmem_export_users( $args, $users = null ) {
99
 
100
  $wp_user_fields = array( 'user_email', 'user_nicename', 'user_url', 'display_name' );
101
  foreach ( $wpmem_fields as $meta ) {
102
- if ( ! in_array( $meta[2], $exclude_fields ) ) {
103
  // @todo Research using fputcsv to escape fields for export.
104
  if ( in_array( $meta[2], $wp_user_fields ) ){
105
  $data .= '"' . $user_info->$meta[2] . '",';
@@ -118,7 +118,7 @@ function wpmem_export_users( $args, $users = null ) {
118
  $data .= "\r\n";
119
 
120
  // Update the user record as being exported.
121
- if ( $export != 'all' ){
122
  update_user_meta( $user, 'exported', 1 );
123
  }
124
  }
38
  'exclude_fields' => array( 'password', 'confirm_password', 'confirm_email' ),
39
  );
40
 
41
+ // Merge $args with defaults.
42
  /**
43
  * Filter the default export arguments.
44
  *
46
  *
47
  * @param array $args An array of arguments to merge with defaults. Default null.
48
  */
49
+ $args = wp_parse_args( apply_filters( 'wpmem_export_args', $args ), $defaults );
50
 
51
  // Output needs to be buffered, start the buffer.
52
  ob_start();
53
 
54
  // If exporting all, get all of the users.
55
+ $users = ( 'all' == $args['export'] ) ? get_users( array( 'fields' => 'ID' ) ) : $users;
56
 
57
  // Generate headers and a filename based on date of export.
58
  header( "Content-Description: File Transfer" );
59
  header( "Content-type: application/octet-stream" );
60
+ header( "Content-Disposition: attachment; filename=" . $args['filename'] );
61
  header( "Content-Type: text/csv; charset=" . get_option( 'blog_charset' ), true );
62
  echo "\xEF\xBB\xBF"; // UTF-8 BOM
63
 
68
  $hrow = "User ID,Username,";
69
 
70
  foreach ( $wpmem_fields as $meta ) {
71
+ if ( ! in_array( $meta[2], $args['exclude_fields'] ) ) {
72
  $hrow.= $meta[1] . ",";
73
  }
74
  }
99
 
100
  $wp_user_fields = array( 'user_email', 'user_nicename', 'user_url', 'display_name' );
101
  foreach ( $wpmem_fields as $meta ) {
102
+ if ( ! in_array( $meta[2], $args['exclude_fields'] ) ) {
103
  // @todo Research using fputcsv to escape fields for export.
104
  if ( in_array( $meta[2], $wp_user_fields ) ){
105
  $data .= '"' . $user_info->$meta[2] . '",';
118
  $data .= "\r\n";
119
 
120
  // Update the user record as being exported.
121
+ if ( 'all' != $args['export'] ){
122
  update_user_meta( $user, 'exported', 1 );
123
  }
124
  }
inc/class-wp-members.php CHANGED
@@ -45,6 +45,8 @@ class WP_Members {
45
  foreach ( $settings as $key => $val ) {
46
  $this->$key = $val;
47
  }
 
 
48
 
49
  // Set the stylesheet.
50
  $this->cssurl = ( isset( $this->style ) && $this->style == 'use_custom' ) ? $this->cssurl : $this->style;
@@ -221,6 +223,10 @@ class WP_Members {
221
  $regchk = wpmem_reset_password();
222
  break;
223
 
 
 
 
 
224
  case 'register':
225
  case 'update':
226
  require_once( WPMEM_PATH . 'inc/register.php' );
@@ -474,5 +480,21 @@ class WP_Members {
474
  // Return excluded fields.
475
  return $excluded_fields;
476
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
 
478
  }
45
  foreach ( $settings as $key => $val ) {
46
  $this->$key = $val;
47
  }
48
+
49
+ $this->load_user_pages();
50
 
51
  // Set the stylesheet.
52
  $this->cssurl = ( isset( $this->style ) && $this->style == 'use_custom' ) ? $this->cssurl : $this->style;
223
  $regchk = wpmem_reset_password();
224
  break;
225
 
226
+ case 'getusername':
227
+ $regchk = wpmem_retrieve_username();
228
+ break;
229
+
230
  case 'register':
231
  case 'update':
232
  require_once( WPMEM_PATH . 'inc/register.php' );
480
  // Return excluded fields.
481
  return $excluded_fields;
482
  }
483
+
484
+ /**
485
+ * Set page locations.
486
+ *
487
+ * Handles numeric page IDs while maintaining
488
+ * compatibility with old full url settings.
489
+ *
490
+ * @since 3.0.8
491
+ */
492
+ function load_user_pages() {
493
+ foreach ( $this->user_pages as $key => $val ) {
494
+ if ( is_numeric( $val ) ) {
495
+ $this->user_pages[ $key ] = get_page_link( $val );
496
+ }
497
+ }
498
+ }
499
 
500
  }
inc/core.php CHANGED
@@ -623,4 +623,45 @@ function wpmem_redirect_to_login() {
623
  }
624
 
625
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
  // End of file.
623
  }
624
 
625
 
626
+ /**
627
+ * Handles retrieving a forgotten username.
628
+ *
629
+ * @since 3.0.8
630
+ *
631
+ * @return string $regchk The regchk value.
632
+ */
633
+ function wpmem_retrieve_username() {
634
+
635
+ if ( isset( $_POST['formsubmit'] ) ) {
636
+
637
+ $user = ( isset( $_POST['user_email'] ) ) ? get_user_by( 'email', $_POST['user_email'] ) : false;
638
+
639
+ if ( $user ) {
640
+
641
+ /**
642
+ * Load the email functions.
643
+ */
644
+ require_once( WPMEM_PATH . 'inc/email.php' );
645
+
646
+ // Send it in an email.
647
+ wpmem_inc_regemail( $user->ID, '', 4 );
648
+
649
+ /**
650
+ * Fires after retrieving username.
651
+ *
652
+ * @since 3.0.8
653
+ *
654
+ * @param int $user_ID The user's numeric ID.
655
+ */
656
+ do_action( 'wpmem_get_username', $user->ID );
657
+
658
+ return 'usernamesuccess';
659
+
660
+ } else {
661
+ return 'usernamefailed';
662
+ }
663
+ }
664
+ return;
665
+ }
666
+
667
  // End of file.
inc/dialogs.php CHANGED
@@ -390,4 +390,104 @@ function wpmem_page_user_edit( $wpmem_regchk, $content ) {
390
  }
391
  endif;
392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
393
  // End of file.
390
  }
391
  endif;
392
 
393
+
394
+ /**
395
+ * Forgot username form.
396
+ *
397
+ * This function creates a form for retrieving a forgotten username.
398
+ *
399
+ * @since 3.0.8
400
+ *
401
+ * @param string $wpmem_regchk
402
+ * @param string $content
403
+ * @return string $content
404
+ */
405
+ function wpmem_page_forgot_username( $wpmem_regchk, $content ) {
406
+
407
+ if ( ! is_user_logged_in() ) {
408
+
409
+ global $wpmem;
410
+ switch( $wpmem->regchk ) {
411
+
412
+ case "usernamefailed":
413
+ $msg = __( 'Sorry, that email address was not found.', 'wp-members' );
414
+ $content = $content
415
+ . wpmem_inc_regmessage( 'usernamefailed', $msg )
416
+ . wpmem_inc_forgotusername();
417
+ $wpmem->regchk = ''; // Clear regchk.
418
+ break;
419
+
420
+ case "usernamesuccess":
421
+ $email = ( isset( $_POST['user_email'] ) ) ? $_POST['user_email'] : '';
422
+ $msg = sprintf( __( 'An email was sent to %s with your username.', 'wp-members' ), $email );
423
+ $content = $content . wpmem_inc_regmessage( 'usernamesuccess', $msg );
424
+ $wpmem->regchk = ''; // Clear regchk.
425
+ break;
426
+
427
+ default:
428
+ $content = $content . wpmem_inc_forgotusername();
429
+ break;
430
+ }
431
+
432
+ }
433
+
434
+ return $content;
435
+
436
+ }
437
+
438
+
439
+ /**
440
+ * Forgot Username Form.
441
+ *
442
+ * Loads the form for retrieving a username.
443
+ *
444
+ * @since 3.0.8
445
+ *
446
+ * @return string $str The generated html for the forgot username form.
447
+ */
448
+ function wpmem_inc_forgotusername() {
449
+
450
+ // create the default inputs
451
+ $default_inputs = array(
452
+ array(
453
+ 'name' => __( 'Email Address', 'wp-members' ),
454
+ 'type' => 'text',
455
+ 'tag' => 'user_email',
456
+ 'class' => 'username',
457
+ 'div' => 'div_text',
458
+ ),
459
+ );
460
+
461
+ /**
462
+ * Filter the array of forgot username form fields.
463
+ *
464
+ * @since 2.9.0
465
+ *
466
+ * @param array $default_inputs An array matching the elements used by default.
467
+ */
468
+ $default_inputs = apply_filters( 'wpmem_inc_forgotusername_inputs', $default_inputs );
469
+
470
+ $defaults = array(
471
+ 'heading' => __( 'Retrieve username', 'wp-members' ),
472
+ 'action' => 'getusername',
473
+ 'button_text' => __( 'Retrieve username', 'wp-members' ),
474
+ 'inputs' => $default_inputs,
475
+ );
476
+
477
+ /**
478
+ * Filter the arguments to override change password form defaults.
479
+ *
480
+ * @since
481
+ *
482
+ * @param array $args An array of arguments to use. Default null.
483
+ */
484
+ $args = apply_filters( 'wpmem_inc_forgotusername_args', '' );
485
+
486
+ $arr = wp_parse_args( $args, $defaults );
487
+
488
+ $str = wpmem_login_form( 'page', $arr );
489
+
490
+ return $str;
491
+ }
492
+
493
  // End of file.
inc/email.php CHANGED
@@ -70,6 +70,12 @@ function wpmem_inc_regemail( $user_id, $password, $toggle, $wpmem_fields = null,
70
  $arr = get_option( 'wpmembers_email_repass' );
71
  $arr['toggle'] = 'repass';
72
  break;
 
 
 
 
 
 
73
 
74
  }
75
 
70
  $arr = get_option( 'wpmembers_email_repass' );
71
  $arr['toggle'] = 'repass';
72
  break;
73
+
74
+ case 4:
75
+ // This is a password reset.
76
+ $arr = get_option( 'wpmembers_email_getuser' );
77
+ $arr['toggle'] = 'getuser';
78
+ break;
79
 
80
  }
81
 
inc/forms.php CHANGED
@@ -258,16 +258,32 @@ if ( ! function_exists( 'wpmem_login_form' ) ):
258
  * @since 2.5.1
259
  *
260
  * @param string $page
261
- * @param array $arr The elements needed to generate the form (login|reset password|forgotten password).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  * @return string $form The HTML for the form as a string.
263
  */
264
  function wpmem_login_form( $page, $arr ) {
265
 
266
  global $wpmem;
267
 
268
- // extract the arguments array
269
- extract( $arr );
270
-
271
  // set up default wrappers
272
  $defaults = array(
273
 
@@ -299,7 +315,7 @@ function wpmem_login_form( $page, $arr ) {
299
  'remember_check' => true,
300
  'n' => "\n",
301
  't' => "\t",
302
- 'redirect_to' => ( isset( $_REQUEST['redirect_to'] ) ) ? esc_url( $_REQUEST['redirect_to'] ) : ( ( isset( $redirect_to ) ) ? $redirect_to : get_permalink() ),
303
 
304
  );
305
 
@@ -312,26 +328,26 @@ function wpmem_login_form( $page, $arr ) {
312
  * @since 2.9.0
313
  *
314
  * @param array An array of arguments to merge with defaults. Default null.
315
- * @param string $action The action being performed by the form. login|pwdreset|pwdchange.
316
  */
317
- $args = apply_filters( 'wpmem_login_form_args', '', $action );
318
 
319
- // merge $args with defaults
320
- extract( wp_parse_args( $args, $defaults ) );
321
 
322
- // build the input rows
323
- foreach ( $inputs as $input ) {
324
  $label = '<label for="' . $input['tag'] . '">' . $input['name'] . '</label>';
325
  $field = wpmem_create_formfield( $input['tag'], $input['type'], '', '', $input['class'] );
326
- $field_before = ( $wrap_inputs ) ? '<div class="' . $input['div'] . '">' : '';
327
- $field_after = ( $wrap_inputs ) ? '</div>' : '';
328
  $rows[] = array(
329
- 'row_before' => $row_before,
330
  'label' => $label,
331
  'field_before' => $field_before,
332
  'field' => $field,
333
  'field_after' => $field_after,
334
- 'row_after' => $row_after,
335
  );
336
  }
337
 
@@ -345,23 +361,23 @@ function wpmem_login_form( $page, $arr ) {
345
  * @since 2.9.0
346
  *
347
  * @param array $rows An array containing the form rows.
348
- * @param string $action The action being performed by the form. login|pwdreset|pwdchange.
349
  */
350
- $rows = apply_filters( 'wpmem_login_form_rows', $rows, $action );
351
 
352
- // put the rows from the array into $form
353
  $form = '';
354
  foreach ( $rows as $row_item ) {
355
- $row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $n . $row_item['label'] . $n : $row_item['label'] . $n;
356
- $row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $n . $t . $row_item['field'] . $n . $row_item['field_after'] . $n : $row_item['field'] . $n;
357
- $row .= ( $row_item['row_before'] != '' ) ? $row_item['row_after'] . $n : '';
358
  $form.= $row;
359
  }
360
 
361
- // build hidden fields, filter, and add to the form
362
- $hidden = wpmem_create_formfield( 'redirect_to', 'hidden', $redirect_to ) . $n;
363
- $hidden = $hidden . wpmem_create_formfield( 'a', 'hidden', $action ) . $n;
364
- $hidden = ( $action != 'login' ) ? $hidden . wpmem_create_formfield( 'formsubmit', 'hidden', '1' ) : $hidden;
365
 
366
  /**
367
  * Filter the hidden field HTML.
@@ -369,16 +385,16 @@ function wpmem_login_form( $page, $arr ) {
369
  * @since 2.9.0
370
  *
371
  * @param string $hidden The generated HTML of hidden fields.
372
- * @param string $action The action being performed by the form. login|pwdreset|pwdchange.
373
  */
374
- $form = $form . apply_filters( 'wpmem_login_hidden_fields', $hidden, $action );
375
 
376
- // build the buttons, filter, and add to the form
377
- if ( $action == 'login' ) {
378
- $remember_check = ( $remember_check ) ? $t . wpmem_create_formfield( 'rememberme', 'checkbox', 'forever' ) . '&nbsp;' . __( 'Remember Me' ) . '&nbsp;&nbsp;' . $n : '';
379
- $buttons = $remember_check . $t . '<input type="submit" name="Submit" value="' . $button_text . '" class="' . $button_class . '" />' . $n;
380
  } else {
381
- $buttons = '<input type="submit" name="Submit" value="' . $button_text . '" class="' . $button_class . '" />' . $n;
382
  }
383
 
384
  /**
@@ -389,11 +405,11 @@ function wpmem_login_form( $page, $arr ) {
389
  * @since 2.9.0
390
  *
391
  * @param string $buttons The generated HTML of the form buttons.
392
- * @param string $action The action being performed by the form. login|pwdreset|pwdchange.
393
  */
394
- $form = $form . apply_filters( 'wpmem_login_form_buttons', $buttons_before . $n . $buttons . $buttons_after . $n, $action );
395
 
396
- if ( ( $wpmem->user_pages['profile'] != null || $page == 'members' ) && $action == 'login' ) {
397
 
398
  /**
399
  * Filter the forgot password link.
@@ -404,11 +420,11 @@ function wpmem_login_form( $page, $arr ) {
404
  */
405
  $link = apply_filters( 'wpmem_forgot_link', wpmem_chk_qstr( $wpmem->user_pages['profile'] ) . 'a=pwdreset' );
406
  $str = __( 'Forgot password?', 'wp-members' ) . '&nbsp;<a href="' . $link . '">' . __( 'Click here to reset', 'wp-members' ) . '</a>';
407
- $form = $form . $link_before . apply_filters( 'wpmem_forgot_link_str', $str ) . $link_after . $n;
408
 
409
  }
410
 
411
- if ( ( $wpmem->user_pages['register'] != null ) && $action == 'login' ) {
412
 
413
  /**
414
  * Filter the link to the registration page.
@@ -419,30 +435,30 @@ function wpmem_login_form( $page, $arr ) {
419
  */
420
  $link = apply_filters( 'wpmem_reg_link', $wpmem->user_pages['register'] );
421
  $str = __( 'New User?', 'wp-members' ) . '&nbsp;<a href="' . $link . '">' . __( 'Click here to register', 'wp-members' ) . '</a>';
422
- $form = $form . $link_before . apply_filters( 'wpmem_reg_link_str', $str ) . $link_after . $n;
423
 
424
  }
425
 
426
- // apply the heading
427
- $form = $heading_before . $heading . $heading_after . $n . $form;
428
 
429
- // apply fieldset wrapper
430
- $form = $fieldset_before . $n . $form . $fieldset_after . $n;
431
 
432
- // apply form wrapper
433
- $form = '<form action="' . get_permalink() . '" method="POST" id="' . $form_id . '" class="' . $form_class . '">' . $n . $form . '</form>';
434
 
435
- // apply anchor
436
- $form = '<a name="' . $action . '"></a>' . $n . $form;
437
 
438
- // apply main wrapper
439
- $form = $main_div_before . $n . $form . $n . $main_div_after;
440
 
441
- // apply wpmem_txt wrapper
442
- $form = $txt_before . $form . $txt_after;
443
 
444
- // remove line breaks
445
- $form = ( $strip_breaks ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
446
 
447
  /**
448
  * Filter the generated HTML of the entire form.
@@ -450,9 +466,9 @@ function wpmem_login_form( $page, $arr ) {
450
  * @since 2.7.4
451
  *
452
  * @param string $form The HTML of the final generated form.
453
- * @param string $action The action being performed by the form. login|pwdreset|pwdchange.
454
  */
455
- $form = apply_filters( 'wpmem_login_form', $form, $action );
456
 
457
  /**
458
  * Filter before the form.
@@ -463,12 +479,12 @@ function wpmem_login_form( $page, $arr ) {
463
  * @since 2.7.4
464
  *
465
  * @param string $str The HTML to add before the form. Default null.
466
- * @param string $action The action being performed by the form. login|pwdreset|pwdchange.
467
  */
468
- $form = apply_filters( 'wpmem_login_form_before', '', $action ) . $form;
469
 
470
  return $form;
471
- } // end wpmem_login_form
472
  endif;
473
 
474
 
@@ -490,10 +506,10 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
490
 
491
  global $wpmem, $wpmem_regchk, $userdata;
492
 
493
- // set up default wrappers
494
  $defaults = array(
495
 
496
- // wrappers
497
  'heading_before' => '<legend>',
498
  'heading_after' => '</legend>',
499
  'fieldset_before' => '<fieldset>',
@@ -507,25 +523,25 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
507
  'buttons_before' => '<div class="button_div">',
508
  'buttons_after' => '</div>',
509
 
510
- // classes & ids
511
  'form_id' => '',
512
  'form_class' => 'form',
513
  'button_id' => '',
514
  'button_class' => 'buttons',
515
 
516
- // required field tags and text
517
- 'req_mark' => '<font class="req">*</font>',
518
- 'req_label' => __( 'Required field', 'wp-members' ),
519
  'req_label_before' => '<div class="req-text">',
520
  'req_label_after' => '</div>',
521
 
522
- // buttons
523
  'show_clear_form' => false,
524
  'clear_form' => __( 'Reset Form', 'wp-members' ),
525
  'submit_register' => __( 'Register' ),
526
  'submit_update' => __( 'Update Profile', 'wp-members' ),
527
 
528
- // other
529
  'strip_breaks' => true,
530
  'use_nonce' => false,
531
  'wrap_inputs' => true,
@@ -547,39 +563,39 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
547
  */
548
  $args = apply_filters( 'wpmem_register_form_args', '', $toggle );
549
 
550
- // merge $args with defaults
551
- extract( wp_parse_args( $args, $defaults ) );
552
 
553
- // Username is editable if new reg, otherwise user profile is not
554
  if ( $toggle == 'edit' ) {
555
- // this is the User Profile edit - username is not editable
556
  $val = $userdata->user_login;
557
  $label = '<label for="username" class="text">' . __( 'Username' ) . '</label>';
558
  $input = '<p class="noinput">' . $val . '</p>';
559
- $field_before = ( $wrap_inputs ) ? '<div class="div_text">' : '';
560
- $field_after = ( $wrap_inputs ) ? '</div>' : '';
561
  } else {
562
- // this is a new registration
563
  $val = ( isset( $_POST['log'] ) ) ? stripslashes( $_POST['log'] ) : '';
564
- $label = '<label for="username" class="text">' . __( 'Choose a Username', 'wp-members' ) . $req_mark . '</label>';
565
  $input = wpmem_create_formfield( 'log', 'text', $val, '', 'username' );
566
 
567
  }
568
- $field_before = ( $wrap_inputs ) ? '<div class="div_text">' : '';
569
- $field_after = ( $wrap_inputs ) ? '</div>': '';
570
 
571
- // add the username row to the array
572
  $rows['username'] = array(
573
  'order' => 0,
574
  'meta' => 'username',
575
  'type' => 'text',
576
  'value' => $val,
577
- 'row_before' => $row_before,
578
  'label' => $label,
579
  'field_before' => $field_before,
580
  'field' => $input,
581
  'field_after' => $field_after,
582
- 'row_after' => $row_after,
583
  );
584
 
585
  /**
@@ -595,40 +611,39 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
595
  * @param array The array of form fields.
596
  * @param string $toggle Toggle new registration or profile update. new|edit.
597
  */
598
- // $wpmem_fields = apply_filters( 'wpmem_register_fields_arr', get_option( 'wpmembers_fields' ), $toggle );
599
  $wpmem_fields = apply_filters( 'wpmem_register_fields_arr', $wpmem->fields, $toggle );
600
 
601
- // loop through the remaining fields
602
  foreach ( $wpmem_fields as $field ) {
603
 
604
- // start with a clean row
605
  $val = ''; $label = ''; $input = ''; $field_before = ''; $field_after = '';
606
 
607
- // skips user selected passwords for profile update
608
  $pass_arr = array( 'password', 'confirm_password', 'password_confirm' );
609
  $do_row = ( $toggle == 'edit' && in_array( $field[2], $pass_arr ) ) ? false : true;
610
 
611
- // skips tos, makes tos field hidden on user edit page, unless they haven't got a value for tos
612
  if ( $field[2] == 'tos' && $toggle == 'edit' && ( get_user_meta( $userdata->ID, 'tos', true ) ) ) {
613
  $do_row = false;
614
  $hidden_tos = wpmem_create_formfield( $field[2], 'hidden', get_user_meta( $userdata->ID, 'tos', true ) );
615
  }
616
 
617
- // if the field is set to display and we aren't skipping, construct the row
618
  if ( $field[4] == 'y' && $do_row == true ) {
619
 
620
- // label for all but TOS
621
  if ( $field[2] != 'tos' ) {
622
 
623
  $class = ( $field[3] == 'password' ) ? 'text' : $field[3];
624
 
625
  $label = '<label for="' . $field[2] . '" class="' . $class . '">' . __( $field[1], 'wp-members' );
626
- $label = ( $field[5] == 'y' ) ? $label . $req_mark : $label;
627
  $label = $label . '</label>';
628
 
629
  }
630
 
631
- // gets the field value for both edit profile and submitted reg w/ error
632
  if ( ( $toggle == 'edit' ) && ( $wpmem_regchk != 'updaterr' ) ) {
633
 
634
  switch ( $field[2] ) {
@@ -638,7 +653,7 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
638
 
639
  case 'user_email':
640
  case 'confirm_email':
641
- $val = $userdata->user_email;
642
  break;
643
 
644
  case 'user_url':
@@ -646,11 +661,11 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
646
  break;
647
 
648
  case 'display_name':
649
- $val = htmlspecialchars( $userdata->display_name );
650
  break;
651
 
652
  default:
653
- $val = htmlspecialchars( get_user_meta( $userdata->ID, $field[2], 'true' ) );
654
  break;
655
  }
656
 
@@ -660,17 +675,17 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
660
 
661
  }
662
 
663
- // does the tos field
664
  if ( $field[2] == 'tos' ) {
665
 
666
  $val = ( isset( $_POST[ $field[2] ] ) ) ? $_POST[ $field[2] ] : '';
667
 
668
- // should be checked by default? and only if form hasn't been submitted
669
  $val = ( ! $_POST && $field[8] == 'y' ) ? $field[7] : $val;
670
  $input = wpmem_create_formfield( $field[2], $field[3], $field[7], $val );
671
- $input = ( $field[5] == 'y' ) ? $input . $req_mark : $input;
672
 
673
- // determine if TOS is a WP page or not...
674
  $tos_content = stripslashes( get_option( 'wpmembers_tos' ) );
675
  if ( ( wpmem_test_shortcode( $tos_content, 'wp-members' ) ) ) {
676
  $link = do_shortcode( $tos_content );
@@ -689,13 +704,13 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
689
  */
690
  $input.= apply_filters( 'wpmem_tos_link_txt', sprintf( __( 'Please indicate that you agree to the %s TOS %s', 'wp-members' ), $tos_pop, '</a>' ), $toggle );
691
 
692
- // in previous versions, the div class would end up being the same as the row before.
693
- $field_before = ( $wrap_inputs ) ? '<div class="div_text">' : '';
694
- $field_after = ( $wrap_inputs ) ? '</div>' : '';
695
 
696
  } else {
697
 
698
- // for checkboxes
699
  if ( $field[3] == 'checkbox' ) {
700
  $valtochk = $val;
701
  $val = $field[7];
@@ -703,7 +718,7 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
703
  if ( $field[8] == 'y' && ( ! $_POST && $toggle != 'edit' ) ) { $val = $valtochk = $field[7]; }
704
  }
705
 
706
- // for dropdown select
707
  if ( $field[3] == 'select' ) {
708
  $valtochk = $val;
709
  $val = $field[7];
@@ -711,34 +726,34 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
711
 
712
  if ( ! isset( $valtochk ) ) { $valtochk = ''; }
713
 
714
- // for all other input types
715
  $input = wpmem_create_formfield( $field[2], $field[3], $val, $valtochk );
716
 
717
- // determine input wrappers
718
- $field_before = ( $wrap_inputs ) ? '<div class="div_' . $class . '">' : '';
719
- $field_after = ( $wrap_inputs ) ? '</div>' : '';
720
  }
721
 
722
  }
723
 
724
- // if the row is set to display, add the row to the form array
725
  if ( $field[4] == 'y' ) {
726
  $rows[$field[2]] = array(
727
  'order' => $field[0],
728
  'meta' => $field[2],
729
  'type' => $field[3],
730
  'value' => $val,
731
- 'row_before' => $row_before,
732
  'label' => $label,
733
  'field_before' => $field_before,
734
  'field' => $input,
735
  'field_after' => $field_after,
736
- 'row_after' => $row_after,
737
  );
738
  }
739
  }
740
 
741
- // if captcha is Really Simple CAPTCHA
742
  if ( $wpmem->captcha == 2 && $toggle != 'edit' ) {
743
  $row = wpmem_build_rs_captcha();
744
  $rows['captcha'] = array(
@@ -746,12 +761,12 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
746
  'meta' => '',
747
  'type' => 'text',
748
  'value' => '',
749
- 'row_before' => $row_before,
750
  'label' => $row['label'],
751
- 'field_before' => ( $wrap_inputs ) ? '<div class="div_text">' : '',
752
  'field' => $row['field'],
753
- 'field_after' => ( $wrap_inputs ) ? '</div>' : '',
754
- 'row_after' => $row_after,
755
  );
756
  }
757
 
@@ -769,28 +784,28 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
769
  */
770
  $rows = apply_filters( 'wpmem_register_form_rows', $rows, $toggle );
771
 
772
- // put the rows from the array into $form
773
  $form = ''; $enctype = '';
774
  foreach ( $rows as $row_item ) {
775
  $enctype = ( $row_item['type'] == 'file' ) ? "multipart/form-data" : $enctype;
776
- $row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $n . $row_item['label'] . $n : $row_item['label'] . $n;
777
- $row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $n . $t . $row_item['field'] . $n . $row_item['field_after'] . $n : $row_item['field'] . $n;
778
- $row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $n : '';
779
  $form.= $row;
780
  }
781
 
782
- // do recaptcha if enabled
783
  if ( ( $wpmem->captcha == 1 || $wpmem->captcha == 3 ) && $toggle != 'edit' ) { // don't show on edit page!
784
 
785
- // get the captcha options
786
  $wpmem_captcha = get_option( 'wpmembers_captcha' );
787
 
788
- // start with a clean row
789
  $row = '';
790
  $row = '<div class="clear"></div>';
791
  $row.= '<div align="right" class="captcha">' . wpmem_inc_recaptcha( $wpmem_captcha['recaptcha'] ) . '</div>';
792
 
793
- // add the captcha row to the form
794
  /**
795
  * Filter the HTML for the CAPTCHA row.
796
  *
@@ -799,18 +814,18 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
799
  * @param string The HTML for the entire row (includes HTML tags plus reCAPTCHA).
800
  * @param string $toggle Toggle new registration or profile update. new|edit.
801
  */
802
- $form.= apply_filters( 'wpmem_register_captcha_row', $row_before . $row . $row_after, $toggle );
803
  }
804
 
805
- // create hidden fields
806
  $var = ( $toggle == 'edit' ) ? 'update' : 'register';
807
  $redirect_to = ( isset( $_REQUEST['redirect_to'] ) ) ? esc_url( $_REQUEST['redirect_to'] ) : ( ( $redirect_to ) ? $redirect_to : get_permalink() );
808
- $hidden = '<input name="a" type="hidden" value="' . $var . '" />' . $n;
809
- $hidden .= '<input name="redirect_to" type="hidden" value="' . $redirect_to . '" />' . $n;
810
  if ( $redirect_to != get_permalink() ) {
811
- $hidden.= '<input name="wpmem_reg_page" type="hidden" value="' . get_permalink() . '" />' . $n;
812
  }
813
- $hidden = ( isset( $hidden_tos ) ) ? $hidden . $hidden_tos . $n : $hidden;
814
 
815
  /**
816
  * Filter the hidden field HTML.
@@ -822,13 +837,13 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
822
  */
823
  $hidden = apply_filters( 'wpmem_register_hidden_fields', $hidden, $toggle );
824
 
825
- // add the hidden fields to the form
826
  $form.= $hidden;
827
 
828
- // create buttons and wrapper
829
- $button_text = ( $toggle == 'edit' ) ? $submit_update : $submit_register;
830
- $buttons = ( $show_clear_form ) ? '<input name="reset" type="reset" value="' . $clear_form . '" class="' . $button_class . '" /> ' . $n : '';
831
- $buttons.= '<input name="submit" type="submit" value="' . $button_text . '" class="' . $button_class . '" />' . $n;
832
 
833
  /**
834
  * Filter the HTML for form buttons.
@@ -842,13 +857,13 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
842
  */
843
  $buttons = apply_filters( 'wpmem_register_form_buttons', $buttons, $toggle );
844
 
845
- // add the buttons to the form
846
- $form.= $buttons_before . $n . $buttons . $buttons_after . $n;
847
 
848
- // add the required field notation to the bottom of the form
849
- $form.= $req_label_before . $req_mark . $req_label . $req_label_after;
850
 
851
- // apply the heading
852
  /**
853
  * Filter the registration form heading.
854
  *
@@ -858,33 +873,33 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
858
  * @param string $toggle Toggle new registration or profile update. new|edit.
859
  */
860
  $heading = ( !$heading ) ? apply_filters( 'wpmem_register_heading', __( 'New User Registration', 'wp-members' ), $toggle ) : $heading;
861
- $form = $heading_before . $heading . $heading_after . $n . $form;
862
 
863
- // apply fieldset wrapper
864
- $form = $fieldset_before . $n . $form . $n . $fieldset_after;
865
 
866
- // apply attribution if enabled
867
  $form = $form . wpmem_inc_attribution();
868
 
869
- // apply nonce
870
- $form = ( defined( 'WPMEM_USE_NONCE' ) || $use_nonce ) ? wp_nonce_field( 'wpmem-validate-submit', 'wpmem-form-submit' ) . $n . $form : $form;
871
 
872
- // apply form wrapper
873
  $enctype = ( $enctype == 'multipart/form-data' ) ? ' enctype="multipart/form-data"' : '';
874
  $post_to = ( $redirect_to ) ? $redirect_to : get_permalink();
875
- $form = '<form name="form" method="post"' . $enctype . ' action="' . $post_to . '" id="' . $form_id . '" class="' . $form_class . '">' . $n . $form. $n . '</form>';
876
 
877
- // apply anchor
878
- $form = '<a name="register"></a>' . $n . $form;
879
 
880
- // apply main div wrapper
881
- $form = $main_div_before . $n . $form . $n . $main_div_after . $n;
882
 
883
- // apply wpmem_txt wrapper
884
- $form = $txt_before . $form . $txt_after;
885
 
886
- // remove line breaks if enabled for easier filtering later
887
- $form = ( $strip_breaks ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
888
 
889
  /**
890
  * Filter the generated HTML of the entire form.
@@ -911,9 +926,9 @@ function wpmem_inc_registration( $toggle = 'new', $heading = '', $redirect_to =
911
  */
912
  $form = apply_filters( 'wpmem_register_form_before', '', $toggle ) . $form;
913
 
914
- // return the generated form
915
  return $form;
916
- } // end wpmem_inc_registration
917
  endif;
918
 
919
 
@@ -928,14 +943,14 @@ if ( ! function_exists( 'wpmem_inc_recaptcha' ) ):
928
  */
929
  function wpmem_inc_recaptcha( $arr ) {
930
 
931
- // determine if reCAPTCHA should be another language
932
  $allowed_langs = array( 'nl', 'fr', 'de', 'pt', 'ru', 'es', 'tr' );
933
  $locale = apply_filters( 'plugin_locale', get_locale(), 'wp-members' );
934
  $compare_lang = strtolower( substr( $locale, -2 ) );
935
  $use_the_lang = ( in_array( $compare_lang, $allowed_langs ) ) ? $compare_lang : false;
936
  $lang = ( $use_the_lang ) ? ' lang : \'' . $use_the_lang . '\'' : '';
937
 
938
- // determine if we need ssl
939
  $http = wpmem_use_ssl();
940
 
941
  global $wpmem;
@@ -1014,21 +1029,22 @@ function wpmem_build_rs_captcha() {
1014
  );
1015
  $wpmem_captcha = get_option( 'wpmembers_captcha' );
1016
 
1017
- extract( wp_parse_args( $wpmem_captcha['really_simple'], $defaults ) );
 
1018
 
1019
- $img_size = array( $dim_w, $dim_h );
1020
- $fg = explode( ",", $font_color );
1021
- $bg = explode( ",", $bg_color );
1022
 
1023
  $wpmem_captcha = new ReallySimpleCaptcha();
1024
- $wpmem_captcha->chars = $characters;
1025
- $wpmem_captcha->char_length = $num_char;
1026
  $wpmem_captcha->img_size = $img_size;
1027
  $wpmem_captcha->fg = $fg;
1028
  $wpmem_captcha->bg = $bg;
1029
- $wpmem_captcha->font_size = $font_size;
1030
- $wpmem_captcha->font_char_width = $kerning;
1031
- $wpmem_captcha->img_type = $img_type;
1032
 
1033
  $wpmem_captcha_word = $wpmem_captcha->generate_random_word();
1034
  $wpmem_captcha_prefix = mt_rand();
@@ -1060,4 +1076,4 @@ function wpmem_build_rs_captcha() {
1060
  }
1061
  }
1062
 
1063
- /** End of File **/
258
  * @since 2.5.1
259
  *
260
  * @param string $page
261
+ * @param array $arr {
262
+ * The elements needed to generate the form (login|reset password|forgotten password).
263
+ *
264
+ * @type string $heading Form heading text.
265
+ * @type string $action The form action (login|pwdchange|pwdreset).
266
+ * @type string $button_text Form submit button text.
267
+ * @type array $inputs {
268
+ * The form input values.
269
+ *
270
+ * @type array {
271
+ *
272
+ * @type string $name The field label.
273
+ * @type string $type Input type.
274
+ * @type string $tag Input tag name.
275
+ * @type string $class Input tag class.
276
+ * @type string $div Div wrapper class.
277
+ * }
278
+ * }
279
+ * @type string $redirect_to Optional. URL to redirect to.
280
+ * }
281
  * @return string $form The HTML for the form as a string.
282
  */
283
  function wpmem_login_form( $page, $arr ) {
284
 
285
  global $wpmem;
286
 
 
 
 
287
  // set up default wrappers
288
  $defaults = array(
289
 
315
  'remember_check' => true,
316
  'n' => "\n",
317
  't' => "\t",
318
+ 'redirect_to' => ( isset( $_REQUEST['redirect_to'] ) ) ? esc_url( $_REQUEST['redirect_to'] ) : ( ( isset( $arr['redirect_to'] ) ) ? $arr['redirect_to'] : get_permalink() ),
319
 
320
  );
321
 
328
  * @since 2.9.0
329
  *
330
  * @param array An array of arguments to merge with defaults. Default null.
331
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
332
  */
333
+ $args = apply_filters( 'wpmem_login_form_args', '', $arr['action'] );
334
 
335
+ // Merge $args with defaults.
336
+ $args = wp_parse_args( $args, $defaults );
337
 
338
+ // Build the input rows.
339
+ foreach ( $arr['inputs'] as $input ) {
340
  $label = '<label for="' . $input['tag'] . '">' . $input['name'] . '</label>';
341
  $field = wpmem_create_formfield( $input['tag'], $input['type'], '', '', $input['class'] );
342
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="' . $input['div'] . '">' : '';
343
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
344
  $rows[] = array(
345
+ 'row_before' => $args['row_before'],
346
  'label' => $label,
347
  'field_before' => $field_before,
348
  'field' => $field,
349
  'field_after' => $field_after,
350
+ 'row_after' => $args['row_after'],
351
  );
352
  }
353
 
361
  * @since 2.9.0
362
  *
363
  * @param array $rows An array containing the form rows.
364
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
365
  */
366
+ $rows = apply_filters( 'wpmem_login_form_rows', $rows, $arr['action'] );
367
 
368
+ // Put the rows from the array into $form.
369
  $form = '';
370
  foreach ( $rows as $row_item ) {
371
+ $row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
372
+ $row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
373
+ $row .= ( $row_item['row_before'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
374
  $form.= $row;
375
  }
376
 
377
+ // Build hidden fields, filter, and add to the form.
378
+ $hidden = wpmem_create_formfield( 'redirect_to', 'hidden', $args['redirect_to'] ) . $args['n'];
379
+ $hidden = $hidden . wpmem_create_formfield( 'a', 'hidden', $arr['action'] ) . $args['n'];
380
+ $hidden = ( $arr['action'] != 'login' ) ? $hidden . wpmem_create_formfield( 'formsubmit', 'hidden', '1' ) : $hidden;
381
 
382
  /**
383
  * Filter the hidden field HTML.
385
  * @since 2.9.0
386
  *
387
  * @param string $hidden The generated HTML of hidden fields.
388
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
389
  */
390
+ $form = $form . apply_filters( 'wpmem_login_hidden_fields', $hidden, $arr['action'] );
391
 
392
+ // Build the buttons, filter, and add to the form.
393
+ if ( $arr['action'] == 'login' ) {
394
+ $args['remember_check'] = ( $args['remember_check'] ) ? $args['t'] . wpmem_create_formfield( 'rememberme', 'checkbox', 'forever' ) . '&nbsp;' . __( 'Remember Me' ) . '&nbsp;&nbsp;' . $args['n'] : '';
395
+ $buttons = $args['remember_check'] . $args['t'] . '<input type="submit" name="Submit" value="' . $arr['button_text'] . '" class="' . $args['button_class'] . '" />' . $args['n'];
396
  } else {
397
+ $buttons = '<input type="submit" name="Submit" value="' . $arr['button_text'] . '" class="' . $args['button_class'] . '" />' . $args['n'];
398
  }
399
 
400
  /**
405
  * @since 2.9.0
406
  *
407
  * @param string $buttons The generated HTML of the form buttons.
408
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
409
  */
410
+ $form = $form . apply_filters( 'wpmem_login_form_buttons', $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'], $arr['action'] );
411
 
412
+ if ( ( $wpmem->user_pages['profile'] != null || $page == 'members' ) && $arr['action'] == 'login' ) {
413
 
414
  /**
415
  * Filter the forgot password link.
420
  */
421
  $link = apply_filters( 'wpmem_forgot_link', wpmem_chk_qstr( $wpmem->user_pages['profile'] ) . 'a=pwdreset' );
422
  $str = __( 'Forgot password?', 'wp-members' ) . '&nbsp;<a href="' . $link . '">' . __( 'Click here to reset', 'wp-members' ) . '</a>';
423
+ $form = $form . $args['link_before'] . apply_filters( 'wpmem_forgot_link_str', $str ) . $args['link_after'] . $args['n'];
424
 
425
  }
426
 
427
+ if ( ( $wpmem->user_pages['register'] != null ) && $arr['action'] == 'login' ) {
428
 
429
  /**
430
  * Filter the link to the registration page.
435
  */
436
  $link = apply_filters( 'wpmem_reg_link', $wpmem->user_pages['register'] );
437
  $str = __( 'New User?', 'wp-members' ) . '&nbsp;<a href="' . $link . '">' . __( 'Click here to register', 'wp-members' ) . '</a>';
438
+ $form = $form . $args['link_before'] . apply_filters( 'wpmem_reg_link_str', $str ) . $args['link_after'] . $args['n'];
439
 
440
  }
441
 
442
+ // Apply the heading.
443
+ $form = $args['heading_before'] . $arr['heading'] . $args['heading_after'] . $args['n'] . $form;
444
 
445
+ // Apply fieldset wrapper.
446
+ $form = $args['fieldset_before'] . $args['n'] . $form . $args['fieldset_after'] . $args['n'];
447
 
448
+ // Apply form wrapper.
449
+ $form = '<form action="' . get_permalink() . '" method="POST" id="' . $args['form_id'] . '" class="' . $args['form_class'] . '">' . $args['n'] . $form . '</form>';
450
 
451
+ // Apply anchor.
452
+ $form = '<a name="' . $arr['action'] . '"></a>' . $args['n'] . $form;
453
 
454
+ // Apply main wrapper.
455
+ $form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'];
456
 
457
+ // Apply wpmem_txt wrapper.
458
+ $form = $args['txt_before'] . $form . $args['txt_after'];
459
 
460
+ // Remove line breaks.
461
+ $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
462
 
463
  /**
464
  * Filter the generated HTML of the entire form.
466
  * @since 2.7.4
467
  *
468
  * @param string $form The HTML of the final generated form.
469
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
470
  */
471
+ $form = apply_filters( 'wpmem_login_form', $form, $arr['action'] );
472
 
473
  /**
474
  * Filter before the form.
479
  * @since 2.7.4
480
  *
481
  * @param string $str The HTML to add before the form. Default null.
482
+ * @param string $arr['action'] The action being performed by the form. login|pwdreset|pwdchange.
483
  */
484
+ $form = apply_filters( 'wpmem_login_form_before', '', $arr['action'] ) . $form;
485
 
486
  return $form;
487
+ } // End wpmem_login_form.
488
  endif;
489
 
490
 
506
 
507
  global $wpmem, $wpmem_regchk, $userdata;
508
 
509
+ // Set up default wrappers.
510
  $defaults = array(
511
 
512
+ // Wrappers.
513
  'heading_before' => '<legend>',
514
  'heading_after' => '</legend>',
515
  'fieldset_before' => '<fieldset>',
523
  'buttons_before' => '<div class="button_div">',
524
  'buttons_after' => '</div>',
525
 
526
+ // Classes & ids.
527
  'form_id' => '',
528
  'form_class' => 'form',
529
  'button_id' => '',
530
  'button_class' => 'buttons',
531
 
532
+ // Required field tags and text.
533
+ 'req_mark' => '<span class="req">*</span>',
534
+ 'req_label' => '<span class="req">*</span>' . __( 'Required field', 'wp-members' ),
535
  'req_label_before' => '<div class="req-text">',
536
  'req_label_after' => '</div>',
537
 
538
+ // Buttons.
539
  'show_clear_form' => false,
540
  'clear_form' => __( 'Reset Form', 'wp-members' ),
541
  'submit_register' => __( 'Register' ),
542
  'submit_update' => __( 'Update Profile', 'wp-members' ),
543
 
544
+ // Other.
545
  'strip_breaks' => true,
546
  'use_nonce' => false,
547
  'wrap_inputs' => true,
563
  */
564
  $args = apply_filters( 'wpmem_register_form_args', '', $toggle );
565
 
566
+ // Merge $args with defaults.
567
+ $args = wp_parse_args( $args, $defaults );
568
 
569
+ // Username is editable if new reg, otherwise user profile is not.
570
  if ( $toggle == 'edit' ) {
571
+ // This is the User Profile edit - username is not editable.
572
  $val = $userdata->user_login;
573
  $label = '<label for="username" class="text">' . __( 'Username' ) . '</label>';
574
  $input = '<p class="noinput">' . $val . '</p>';
575
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
576
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
577
  } else {
578
+ // This is a new registration.
579
  $val = ( isset( $_POST['log'] ) ) ? stripslashes( $_POST['log'] ) : '';
580
+ $label = '<label for="username" class="text">' . __( 'Choose a Username', 'wp-members' ) . $args['req_mark'] . '</label>';
581
  $input = wpmem_create_formfield( 'log', 'text', $val, '', 'username' );
582
 
583
  }
584
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
585
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>': '';
586
 
587
+ // Add the username row to the array.
588
  $rows['username'] = array(
589
  'order' => 0,
590
  'meta' => 'username',
591
  'type' => 'text',
592
  'value' => $val,
593
+ 'row_before' => $args['row_before'],
594
  'label' => $label,
595
  'field_before' => $field_before,
596
  'field' => $input,
597
  'field_after' => $field_after,
598
+ 'row_after' => $args['row_after'],
599
  );
600
 
601
  /**
611
  * @param array The array of form fields.
612
  * @param string $toggle Toggle new registration or profile update. new|edit.
613
  */
 
614
  $wpmem_fields = apply_filters( 'wpmem_register_fields_arr', $wpmem->fields, $toggle );
615
 
616
+ // Loop through the remaining fields.
617
  foreach ( $wpmem_fields as $field ) {
618
 
619
+ // Start with a clean row.
620
  $val = ''; $label = ''; $input = ''; $field_before = ''; $field_after = '';
621
 
622
+ // Skips user selected passwords for profile update.
623
  $pass_arr = array( 'password', 'confirm_password', 'password_confirm' );
624
  $do_row = ( $toggle == 'edit' && in_array( $field[2], $pass_arr ) ) ? false : true;
625
 
626
+ // Skips tos, makes tos field hidden on user edit page, unless they haven't got a value for tos.
627
  if ( $field[2] == 'tos' && $toggle == 'edit' && ( get_user_meta( $userdata->ID, 'tos', true ) ) ) {
628
  $do_row = false;
629
  $hidden_tos = wpmem_create_formfield( $field[2], 'hidden', get_user_meta( $userdata->ID, 'tos', true ) );
630
  }
631
 
632
+ // If the field is set to display and we aren't skipping, construct the row.
633
  if ( $field[4] == 'y' && $do_row == true ) {
634
 
635
+ // Label for all but TOS.
636
  if ( $field[2] != 'tos' ) {
637
 
638
  $class = ( $field[3] == 'password' ) ? 'text' : $field[3];
639
 
640
  $label = '<label for="' . $field[2] . '" class="' . $class . '">' . __( $field[1], 'wp-members' );
641
+ $label = ( $field[5] == 'y' ) ? $label . $args['req_mark'] : $label;
642
  $label = $label . '</label>';
643
 
644
  }
645
 
646
+ // Gets the field value for both edit profile and submitted reg w/ error.
647
  if ( ( $toggle == 'edit' ) && ( $wpmem_regchk != 'updaterr' ) ) {
648
 
649
  switch ( $field[2] ) {
653
 
654
  case 'user_email':
655
  case 'confirm_email':
656
+ $val = sanitize_email( $userdata->user_email );
657
  break;
658
 
659
  case 'user_url':
661
  break;
662
 
663
  case 'display_name':
664
+ $val = sanitize_text_field( $userdata->display_name );
665
  break;
666
 
667
  default:
668
+ $val = sanitize_text_field( get_user_meta( $userdata->ID, $field[2], 'true' ) );
669
  break;
670
  }
671
 
675
 
676
  }
677
 
678
+ // Does the tos field.
679
  if ( $field[2] == 'tos' ) {
680
 
681
  $val = ( isset( $_POST[ $field[2] ] ) ) ? $_POST[ $field[2] ] : '';
682
 
683
+ // Should be checked by default? and only if form hasn't been submitted.
684
  $val = ( ! $_POST && $field[8] == 'y' ) ? $field[7] : $val;
685
  $input = wpmem_create_formfield( $field[2], $field[3], $field[7], $val );
686
+ $input = ( $field[5] == 'y' ) ? $input . $args['req_mark'] : $input;
687
 
688
+ // Determine if TOS is a WP page or not.
689
  $tos_content = stripslashes( get_option( 'wpmembers_tos' ) );
690
  if ( ( wpmem_test_shortcode( $tos_content, 'wp-members' ) ) ) {
691
  $link = do_shortcode( $tos_content );
704
  */
705
  $input.= apply_filters( 'wpmem_tos_link_txt', sprintf( __( 'Please indicate that you agree to the %s TOS %s', 'wp-members' ), $tos_pop, '</a>' ), $toggle );
706
 
707
+ // In previous versions, the div class would end up being the same as the row before.
708
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
709
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
710
 
711
  } else {
712
 
713
+ // For checkboxes.
714
  if ( $field[3] == 'checkbox' ) {
715
  $valtochk = $val;
716
  $val = $field[7];
718
  if ( $field[8] == 'y' && ( ! $_POST && $toggle != 'edit' ) ) { $val = $valtochk = $field[7]; }
719
  }
720
 
721
+ // For dropdown select.
722
  if ( $field[3] == 'select' ) {
723
  $valtochk = $val;
724
  $val = $field[7];
726
 
727
  if ( ! isset( $valtochk ) ) { $valtochk = ''; }
728
 
729
+ // For all other input types.
730
  $input = wpmem_create_formfield( $field[2], $field[3], $val, $valtochk );
731
 
732
+ // Determine input wrappers.
733
+ $field_before = ( $args['wrap_inputs'] ) ? '<div class="div_' . $class . '">' : '';
734
+ $field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
735
  }
736
 
737
  }
738
 
739
+ // If the row is set to display, add the row to the form array.
740
  if ( $field[4] == 'y' ) {
741
  $rows[$field[2]] = array(
742
  'order' => $field[0],
743
  'meta' => $field[2],
744
  'type' => $field[3],
745
  'value' => $val,
746
+ 'row_before' => $args['row_before'],
747
  'label' => $label,
748
  'field_before' => $field_before,
749
  'field' => $input,
750
  'field_after' => $field_after,
751
+ 'row_after' => $args['row_after'],
752
  );
753
  }
754
  }
755
 
756
+ // If captcha is Really Simple CAPTCHA.
757
  if ( $wpmem->captcha == 2 && $toggle != 'edit' ) {
758
  $row = wpmem_build_rs_captcha();
759
  $rows['captcha'] = array(
761
  'meta' => '',
762
  'type' => 'text',
763
  'value' => '',
764
+ 'row_before' => $args['row_before'],
765
  'label' => $row['label'],
766
+ 'field_before' => ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '',
767
  'field' => $row['field'],
768
+ 'field_after' => ( $args['wrap_inputs'] ) ? '</div>' : '',
769
+ 'row_after' => $args['row_after'],
770
  );
771
  }
772
 
784
  */
785
  $rows = apply_filters( 'wpmem_register_form_rows', $rows, $toggle );
786
 
787
+ // Put the rows from the array into $form.
788
  $form = ''; $enctype = '';
789
  foreach ( $rows as $row_item ) {
790
  $enctype = ( $row_item['type'] == 'file' ) ? "multipart/form-data" : $enctype;
791
+ $row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
792
+ $row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
793
+ $row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
794
  $form.= $row;
795
  }
796
 
797
+ // Do recaptcha if enabled.
798
  if ( ( $wpmem->captcha == 1 || $wpmem->captcha == 3 ) && $toggle != 'edit' ) { // don't show on edit page!
799
 
800
+ // Get the captcha options.
801
  $wpmem_captcha = get_option( 'wpmembers_captcha' );
802
 
803
+ // Start with a clean row.
804
  $row = '';
805
  $row = '<div class="clear"></div>';
806
  $row.= '<div align="right" class="captcha">' . wpmem_inc_recaptcha( $wpmem_captcha['recaptcha'] ) . '</div>';
807
 
808
+ // Add the captcha row to the form.
809
  /**
810
  * Filter the HTML for the CAPTCHA row.
811
  *
814
  * @param string The HTML for the entire row (includes HTML tags plus reCAPTCHA).
815
  * @param string $toggle Toggle new registration or profile update. new|edit.
816
  */
817
+ $form.= apply_filters( 'wpmem_register_captcha_row', $args['row_before'] . $row . $args['row_after'], $toggle );
818
  }
819
 
820
+ // Create hidden fields.
821
  $var = ( $toggle == 'edit' ) ? 'update' : 'register';
822
  $redirect_to = ( isset( $_REQUEST['redirect_to'] ) ) ? esc_url( $_REQUEST['redirect_to'] ) : ( ( $redirect_to ) ? $redirect_to : get_permalink() );
823
+ $hidden = '<input name="a" type="hidden" value="' . $var . '" />' . $args['n'];
824
+ $hidden .= '<input name="redirect_to" type="hidden" value="' . $redirect_to . '" />' . $args['n'];
825
  if ( $redirect_to != get_permalink() ) {
826
+ $hidden.= '<input name="wpmem_reg_page" type="hidden" value="' . get_permalink() . '" />' . $args['n'];
827
  }
828
+ $hidden = ( isset( $hidden_tos ) ) ? $hidden . $hidden_tos . $args['n'] : $hidden;
829
 
830
  /**
831
  * Filter the hidden field HTML.
837
  */
838
  $hidden = apply_filters( 'wpmem_register_hidden_fields', $hidden, $toggle );
839
 
840
+ // Add the hidden fields to the form.
841
  $form.= $hidden;
842
 
843
+ // Create buttons and wrapper.
844
+ $button_text = ( $toggle == 'edit' ) ? $args['submit_update'] : $args['submit_register'];
845
+ $buttons = ( $args['show_clear_form'] ) ? '<input name="reset" type="reset" value="' . $args['clear_form'] . '" class="' . $args['button_class'] . '" /> ' . $args['n'] : '';
846
+ $buttons.= '<input name="submit" type="submit" value="' . $button_text . '" class="' . $args['button_class'] . '" />' . $args['n'];
847
 
848
  /**
849
  * Filter the HTML for form buttons.
857
  */
858
  $buttons = apply_filters( 'wpmem_register_form_buttons', $buttons, $toggle );
859
 
860
+ // Add the buttons to the form.
861
+ $form.= $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'];
862
 
863
+ // Add the required field notation to the bottom of the form.
864
+ $form.= $args['req_label_before'] . $args['req_label'] . $args['req_label_after'];
865
 
866
+ // Apply the heading.
867
  /**
868
  * Filter the registration form heading.
869
  *
873
  * @param string $toggle Toggle new registration or profile update. new|edit.
874
  */
875
  $heading = ( !$heading ) ? apply_filters( 'wpmem_register_heading', __( 'New User Registration', 'wp-members' ), $toggle ) : $heading;
876
+ $form = $args['heading_before'] . $heading . $args['heading_after'] . $args['n'] . $form;
877
 
878
+ // Apply fieldset wrapper.
879
+ $form = $args['fieldset_before'] . $args['n'] . $form . $args['n'] . $args['fieldset_after'];
880
 
881
+ // Apply attribution if enabled.
882
  $form = $form . wpmem_inc_attribution();
883
 
884
+ // Apply nonce.
885
+ $form = ( defined( 'WPMEM_USE_NONCE' ) || $args['use_nonce'] ) ? wp_nonce_field( 'wpmem-validate-submit', 'wpmem-form-submit' ) . $args['n'] . $form : $form;
886
 
887
+ // Apply form wrapper.
888
  $enctype = ( $enctype == 'multipart/form-data' ) ? ' enctype="multipart/form-data"' : '';
889
  $post_to = ( $redirect_to ) ? $redirect_to : get_permalink();
890
+ $form = '<form name="form" method="post"' . $enctype . ' action="' . $post_to . '" id="' . $args['form_id'] . '" class="' . $args['form_class'] . '">' . $args['n'] . $form . $args['n'] . '</form>';
891
 
892
+ // Apply anchor.
893
+ $form = '<a name="register"></a>' . $args['n'] . $form;
894
 
895
+ // Apply main div wrapper.
896
+ $form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'] . $args['n'];
897
 
898
+ // Apply wpmem_txt wrapper.
899
+ $form = $args['txt_before'] . $form . $args['txt_after'];
900
 
901
+ // Remove line breaks if enabled for easier filtering later.
902
+ $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
903
 
904
  /**
905
  * Filter the generated HTML of the entire form.
926
  */
927
  $form = apply_filters( 'wpmem_register_form_before', '', $toggle ) . $form;
928
 
929
+ // Return the generated form.
930
  return $form;
931
+ } // End wpmem_inc_registration.
932
  endif;
933
 
934
 
943
  */
944
  function wpmem_inc_recaptcha( $arr ) {
945
 
946
+ // Determine if reCAPTCHA should be another language.
947
  $allowed_langs = array( 'nl', 'fr', 'de', 'pt', 'ru', 'es', 'tr' );
948
  $locale = apply_filters( 'plugin_locale', get_locale(), 'wp-members' );
949
  $compare_lang = strtolower( substr( $locale, -2 ) );
950
  $use_the_lang = ( in_array( $compare_lang, $allowed_langs ) ) ? $compare_lang : false;
951
  $lang = ( $use_the_lang ) ? ' lang : \'' . $use_the_lang . '\'' : '';
952
 
953
+ // Determine if we need ssl.
954
  $http = wpmem_use_ssl();
955
 
956
  global $wpmem;
1029
  );
1030
  $wpmem_captcha = get_option( 'wpmembers_captcha' );
1031
 
1032
+ $args = ( isset( $wpmem_captcha['really_simple'] ) && is_array( $wpmem_captcha['really_simple'] ) ) ? $wpmem_captcha['really_simple'] : array();
1033
+ $args = wp_parse_args( $args, $defaults );
1034
 
1035
+ $img_size = array( $args['dim_w'], $args['dim_h'] );
1036
+ $fg = explode( ",", $args['font_color'] );
1037
+ $bg = explode( ",", $args['bg_color'] );
1038
 
1039
  $wpmem_captcha = new ReallySimpleCaptcha();
1040
+ $wpmem_captcha->chars = $args['characters'];
1041
+ $wpmem_captcha->char_length = $args['num_char'];
1042
  $wpmem_captcha->img_size = $img_size;
1043
  $wpmem_captcha->fg = $fg;
1044
  $wpmem_captcha->bg = $bg;
1045
+ $wpmem_captcha->font_size = $args['font_size'];
1046
+ $wpmem_captcha->font_char_width = $args['kerning'];
1047
+ $wpmem_captcha->img_type = $args['img_type'];
1048
 
1049
  $wpmem_captcha_word = $wpmem_captcha->generate_random_word();
1050
  $wpmem_captcha_prefix = mt_rand();
1076
  }
1077
  }
1078
 
1079
+ // End of file.
inc/shortcodes.php CHANGED
@@ -439,6 +439,10 @@ function wpmem_do_sc_pages( $page, $redirect_to = null ) {
439
 
440
  $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
441
 
 
 
 
 
442
  } else {
443
 
444
  $content = ( $page == 'members-area' ) ? $content . wpmem_inc_login( 'members' ) : $content;
439
 
440
  $content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
441
 
442
+ } elseif( $wpmem->action == 'getusername' ) {
443
+
444
+ $content = wpmem_page_forgot_username( $wpmem->regchk, $content );
445
+
446
  } else {
447
 
448
  $content = ( $page == 'members-area' ) ? $content . wpmem_inc_login( 'members' ) : $content;
inc/sidebar.php CHANGED
@@ -130,27 +130,27 @@ function wpmem_do_sidebar( $post_to = null ) {
130
  $args = apply_filters( 'wpmem_sb_login_args', '' );
131
 
132
  // Merge $args with defaults.
133
- extract( wp_parse_args( $args, $defaults ) );
134
 
135
  $form = '';
136
 
137
  $label = '<label for="username">' . __( 'Username' ) . '</label>';
138
  $input = '<input type="text" name="log" class="username" id="username" />';
139
 
140
- $input = ( $wrap_inputs ) ? $inputs_before . $input . $inputs_after : $input;
141
- $row1 = $label . $n . $input . $n;
142
 
143
  $label = '<label for="password">' . __( 'Password' ) . '</label>';
144
  $input = '<input type="password" name="pwd" class="password" id="password" />';
145
 
146
- $input = ( $wrap_inputs ) ? $inputs_before . $input . $inputs_after : $input;
147
- $row2 = $label . $n . $input . $n;
148
 
149
  $form = $row1 . $row2;
150
 
151
- $hidden = '<input type="hidden" name="rememberme" value="forever" />' . $n .
152
- '<input type="hidden" name="redirect_to" value="' . $post_to . '" />' . $n .
153
- '<input type="hidden" name="a" value="login" />' . $n .
154
  '<input type="hidden" name="slog" value="true" />';
155
  /**
156
  * Filter sidebar login form hidden fields.
@@ -188,17 +188,17 @@ function wpmem_do_sidebar( $post_to = null ) {
188
  $buttons.= ' <a href="' . $link . '">' . __( 'Register' ) . '</a>';
189
  }
190
 
191
- $form = $form . $n . $buttons_before . $buttons . $n . $buttons_after;
192
 
193
- $form = $fieldset_before . $n . $form . $n . $fieldset_after;
194
 
195
- $form = '<form name="form" method="post" action="' . $post_to . '">' . $n . $form . $n . '</form>';
196
 
197
  // Add status message.
198
- $form = $status_msg . $n . $form;
199
 
200
  // Strip breaks.
201
- $form = ( $strip_breaks ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
202
 
203
  /**
204
  * Filter the sidebar form.
@@ -212,7 +212,7 @@ function wpmem_do_sidebar( $post_to = null ) {
212
  $do_error_msg = '';
213
  if ( isset( $_POST['slog'] ) && $wpmem_regchk == 'loginfailed' ) {
214
  $do_error_msg = true;
215
- $error_msg = $error_before . $error_msg . $error_after;
216
  /**
217
  * Filter the sidebar login failed message.
218
  *
130
  $args = apply_filters( 'wpmem_sb_login_args', '' );
131
 
132
  // Merge $args with defaults.
133
+ $args = wp_parse_args( $args, $defaults );
134
 
135
  $form = '';
136
 
137
  $label = '<label for="username">' . __( 'Username' ) . '</label>';
138
  $input = '<input type="text" name="log" class="username" id="username" />';
139
 
140
+ $input = ( $args['wrap_inputs'] ) ? $args['inputs_before'] . $input . $args['inputs_after'] : $input;
141
+ $row1 = $label . $args['n'] . $input . $args['n'];
142
 
143
  $label = '<label for="password">' . __( 'Password' ) . '</label>';
144
  $input = '<input type="password" name="pwd" class="password" id="password" />';
145
 
146
+ $input = ( $args['wrap_inputs'] ) ? $args['inputs_before'] . $input . $args['inputs_after'] : $input;
147
+ $row2 = $label . $args['n'] . $input . $args['n'];
148
 
149
  $form = $row1 . $row2;
150
 
151
+ $hidden = '<input type="hidden" name="rememberme" value="forever" />' . $args['n'] .
152
+ '<input type="hidden" name="redirect_to" value="' . $post_to . '" />' . $args['n'] .
153
+ '<input type="hidden" name="a" value="login" />' . $args['n'] .
154
  '<input type="hidden" name="slog" value="true" />';
155
  /**
156
  * Filter sidebar login form hidden fields.
188
  $buttons.= ' <a href="' . $link . '">' . __( 'Register' ) . '</a>';
189
  }
190
 
191
+ $form = $form . $args['n'] . $args['buttons_before'] . $buttons . $args['n'] . $args['buttons_after'];
192
 
193
+ $form = $args['fieldset_before'] . $args['n'] . $form . $args['n'] . $args['fieldset_after'];
194
 
195
+ $form = '<form name="form" method="post" action="' . $post_to . '">' . $args['n'] . $form . $args['n'] . '</form>';
196
 
197
  // Add status message.
198
+ $form = $args['status_msg'] . $args['n'] . $form;
199
 
200
  // Strip breaks.
201
+ $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
202
 
203
  /**
204
  * Filter the sidebar form.
212
  $do_error_msg = '';
213
  if ( isset( $_POST['slog'] ) && $wpmem_regchk == 'loginfailed' ) {
214
  $do_error_msg = true;
215
+ $error_msg = $args['error_before'] . $args['error_msg'] . $args['error_after'];
216
  /**
217
  * Filter the sidebar login failed message.
218
  *
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.1
5
- Tested up to: 4.3.1
6
- Stable tag: 3.0.7
7
  License: GPLv2
8
 
9
  WP-Members&trade; is a free membership management framework for WordPress&reg; that restricts content to registered users.
@@ -111,6 +111,7 @@ Premium priority support is available at the plugin's site [RocketGeek.com](http
111
 
112
  == Upgrade Notice ==
113
 
 
114
  WP-Members 3.0.0 is a major version release. Please review the changelog: http://rkt.bz/v30
115
 
116
  == Screenshots ==
@@ -134,6 +135,12 @@ WP-Members 3.0.0 is a major version release. Please review the changelog: http:/
134
 
135
  == Changelog ==
136
 
 
 
 
 
 
 
137
  = 3.0.7 =
138
 
139
  * Fix for use of display_name on profile update.
2
  Contributors: cbutlerjr
3
  Tags: access, authentication, content, login, member, membership, password, protect, register, registration, restriction, subscriber
4
  Requires at least: 3.1
5
+ Tested up to: 4.4.0
6
+ Stable tag: 3.0.8
7
  License: GPLv2
8
 
9
  WP-Members&trade; is a free membership management framework for WordPress&reg; that restricts content to registered users.
111
 
112
  == Upgrade Notice ==
113
 
114
+ WP-Members 3.0.8 is a feature release, see release notes.
115
  WP-Members 3.0.0 is a major version release. Please review the changelog: http://rkt.bz/v30
116
 
117
  == Screenshots ==
135
 
136
  == Changelog ==
137
 
138
+ = 3.0.8 =
139
+
140
+ * Added process for forgotten username retrieval.
141
+ * Removed last remaining instances of extract function.
142
+ * 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.
143
+
144
  = 3.0.7 =
145
 
146
  * Fix for use of display_name on profile update.
uninstall.php CHANGED
@@ -56,14 +56,15 @@ function wpmem_uninstall_options() {
56
  delete_option( 'wpmembers_export' );
57
  delete_option( 'wpmembers_utfields' );
58
 
59
- delete_option( 'wpmembers_email_newreg' );
60
- delete_option( 'wpmembers_email_newmod' );
61
- delete_option( 'wpmembers_email_appmod' );
62
- delete_option( 'wpmembers_email_repass' );
63
- delete_option( 'wpmembers_email_footer' );
64
- delete_option( 'wpmembers_email_notify' );
65
- delete_option( 'wpmembers_email_wpfrom' );
66
- delete_option( 'wpmembers_email_wpname' );
 
67
 
68
  delete_option( 'widget_wpmemwidget' );
69
 
56
  delete_option( 'wpmembers_export' );
57
  delete_option( 'wpmembers_utfields' );
58
 
59
+ delete_option( 'wpmembers_email_newreg' );
60
+ delete_option( 'wpmembers_email_newmod' );
61
+ delete_option( 'wpmembers_email_appmod' );
62
+ delete_option( 'wpmembers_email_repass' );
63
+ delete_option( 'wpmembers_email_footer' );
64
+ delete_option( 'wpmembers_email_notify' );
65
+ delete_option( 'wpmembers_email_wpfrom' );
66
+ delete_option( 'wpmembers_email_wpname' );
67
+ delete_option( 'wpmembers_email_getuser' );
68
 
69
  delete_option( 'widget_wpmemwidget' );
70
 
wp-members-install.php CHANGED
@@ -84,7 +84,7 @@ function wpmem_do_install() {
84
 
85
  // Using update_option to allow for forced update.
86
  update_option( 'wpmembers_settings', $wpmem_settings, '', 'yes' );
87
-
88
  /*
89
  * Field array elements:
90
  *
@@ -366,6 +366,24 @@ Please do not reply to this address';
366
  if ( ! get_option( 'wpmembers_email_footer' ) ) {
367
  update_option( 'wpmembers_email_footer', $body, false );
368
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
 
370
  return true;
371
  }
84
 
85
  // Using update_option to allow for forced update.
86
  update_option( 'wpmembers_settings', $wpmem_settings, '', 'yes' );
87
+
88
  /*
89
  * Field array elements:
90
  *
366
  if ( ! get_option( 'wpmembers_email_footer' ) ) {
367
  update_option( 'wpmembers_email_footer', $body, false );
368
  }
369
+
370
+ $arr = $subj = $body = '';
371
+
372
+ // Email for retrieve username.
373
+ $subj = 'Username for [blogname]';
374
+ $body = 'Your username for [blogname] is below.
375
+
376
+ username: [username]
377
+ ';
378
+
379
+ $arr = array(
380
+ "subj" => $subj,
381
+ "body" => $body,
382
+ );
383
+
384
+ if ( ! get_option( 'wpmembers_email_getuser' ) ) {
385
+ update_option( 'wpmembers_email_getuser', $arr, false );
386
+ }
387
 
388
  return true;
389
  }
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.0.7.2
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.0.7.2' );
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.0.8
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.0.8' );
66
  define( 'WPMEM_DEBUG', false );
67
  define( 'WPMEM_DIR', plugin_dir_url ( __FILE__ ) );
68
  define( 'WPMEM_PATH', plugin_dir_path( __FILE__ ) );