New User Approve - Version 1.6

Version Description

  • improve actions and filters
  • refactor messages to make them easier to override
  • show admin notice if the membership setting is turned off
  • fix bug preventing approvals/denials when using filter
  • add sidebar in admin to help with support
  • unit tests
  • shake the login form when attempting to login as unapproved user
  • updated French translation
Download this release

Release Info

Developer picklewagon
Plugin Icon 128x128 New User Approve
Version 1.6
Comparing to
See all releases

Code changes from version 1.5.8 to 1.6

.travis.yml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ php:
4
+ - 5.3
5
+ - 5.4
6
+
7
+ env:
8
+ - WP_VERSION=master WP_MULTISITE=0
9
+ - WP_VERSION=master WP_MULTISITE=1
10
+ - WP_VERSION=3.5.1 WP_MULTISITE=0
11
+ - WP_VERSION=3.5.1 WP_MULTISITE=1
12
+
13
+ before_script:
14
+ - export WP_TESTS_DIR=/tmp/wordpress-tests/
15
+ - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
16
+
17
+ script: phpunit
admin/templates/approve.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php require_once('includes/template.php'); // WordPress Dashboard Functions ?>
3
+
4
+ <?php
5
+ if ( isset( $_GET['user'] ) && isset( $_GET['status'] ) ) {
6
+ echo '<div id="message" class="updated fade"><p>' . __( 'User successfully updated.', 'new-user-approve' ) . '</p></div>';
7
+ }
8
+ ?>
9
+
10
+ <div class="wrap">
11
+ <h2><?php _e( 'User Registration Approval', 'new-user-approve' ); ?></h2>
12
+
13
+ <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
14
+ <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
15
+
16
+ <div id="poststuff" class="columns metabox-holder">
17
+ <div id="post-body" class="metabox-holder columns-2">
18
+ <div id="postbox-container-1" class="postbox-container column-secondary">
19
+ <?php do_meta_boxes( 'users_page_new-user-approve-admin', 'side', $this ); ?>
20
+ </div>
21
+ <div id="postbox-container-2" class="postbox-container column-primary">
22
+ <?php do_meta_boxes( 'users_page_new-user-approve-admin', 'main', $this ); ?>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
bin/install-wp-tests.sh ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ if [ $# -lt 3 ]; then
4
+ echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
5
+ exit 1
6
+ fi
7
+
8
+ DB_NAME=$1
9
+ DB_USER=$2
10
+ DB_PASS=$3
11
+ DB_HOST=${4-localhost}
12
+ WP_VERSION=${5-master}
13
+
14
+ set -ex
15
+
16
+ # set up a WP install
17
+ WP_CORE_DIR=/tmp/wordpress/
18
+ mkdir -p $WP_CORE_DIR
19
+ wget -nv -O /tmp/wordpress.tar.gz https://github.com/WordPress/WordPress/tarball/$WP_VERSION
20
+ tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
21
+
22
+ # set up testing suite
23
+ svn co --ignore-externals --quiet http://unit-tests.svn.wordpress.org/trunk/ $WP_TESTS_DIR
24
+
25
+ # portable in-place argument for both GNU sed and Mac OSX sed
26
+ if [[ $(uname -s) == 'Darwin' ]]; then
27
+ ioption='-i ""'
28
+ else
29
+ ioption='-i'
30
+ fi
31
+
32
+ # generate testing config file
33
+ cd $WP_TESTS_DIR
34
+ cp wp-tests-config-sample.php wp-tests-config.php
35
+ sed $ioption "s:dirname( __FILE__ ) . '/wordpress/':'$WP_CORE_DIR':" wp-tests-config.php
36
+ sed $ioption "s/yourdbnamehere/$DB_NAME/" wp-tests-config.php
37
+ sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
38
+ sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
39
+ sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
40
+
41
+ # parse DB_HOST for port or socket references
42
+ PARTS=(${DB_HOST//\:/ })
43
+ DB_HOSTNAME=${PARTS[0]};
44
+ DB_SOCK_OR_PORT=${PARTS[1]};
45
+ EXTRA=""
46
+
47
+ if ! [ -z $DB_HOSTNAME ] ; then
48
+ if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
49
+ EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
50
+ elif ! [ -z $DB_SOCK_OR_PORT ] ; then
51
+ EXTRA=" --socket=$DB_SOCK_OR_PORT"
52
+ elif ! [ -z $DB_HOSTNAME ] ; then
53
+ EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
54
+ fi
55
+ fi
56
+
57
+ # create database
58
+ mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
includes/admin-approve.php CHANGED
@@ -34,6 +34,7 @@ class pw_new_user_approve_admin_approve {
34
  add_action( 'admin_init', array( $this, 'process_input' ) );
35
  add_action( 'admin_notices', array( $this, 'admin_notice' ) );
36
  add_action( 'admin_init', array( $this, 'notice_ignore' ) );
 
37
  }
38
 
39
  /**
@@ -46,7 +47,9 @@ class pw_new_user_approve_admin_approve {
46
 
47
  if ( $show_admin_page ) {
48
  $cap = apply_filters( 'new_user_approve_minimum_cap', 'edit_users' );
49
- add_users_page( __( 'Approve New Users', 'new-user-approve' ), __( 'Approve New Users', 'new-user-approve' ), $cap, $this->_admin_page, array( $this, 'approve_admin' ) );
 
 
50
  }
51
  }
52
 
@@ -54,40 +57,11 @@ class pw_new_user_approve_admin_approve {
54
  * Create the view for the admin interface
55
  */
56
  public function approve_admin() {
57
- if ( isset( $_GET['user'] ) && isset( $_GET['status'] ) ) {
58
- echo '<div id="message" class="updated fade"><p>' . __( 'User successfully updated.', 'new-user-approve' ) . '</p></div>';
59
  }
60
 
61
- $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'pending_users';
62
- ?>
63
- <div class="wrap">
64
- <h2><?php _e( 'User Registration Approval', 'new-user-approve' ); ?></h2>
65
-
66
- <h3 class="nav-tab-wrapper">
67
- <a href="<?php echo esc_url( admin_url( 'users.php?page=new-user-approve-admin&tab=pending_users' ) ); ?>"
68
- class="nav-tab<?php echo $active_tab == 'pending_users' ? ' nav-tab-active' : ''; ?>"><span><?php _e( 'Users Pending Approval', 'new-user-approve' ); ?></span></a>
69
- <a href="<?php echo esc_url( admin_url( 'users.php?page=new-user-approve-admin&tab=approved_users' ) ); ?>"
70
- class="nav-tab<?php echo $active_tab == 'approved_users' ? ' nav-tab-active' : ''; ?>"><span><?php _e( 'Approved Users', 'new-user-approve' ); ?></span></a>
71
- <a href="<?php echo esc_url( admin_url( 'users.php?page=new-user-approve-admin&tab=denied_users' ) ); ?>"
72
- class="nav-tab<?php echo $active_tab == 'denied_users' ? ' nav-tab-active' : ''; ?>"><span><?php _e( 'Denied Users', 'new-user-approve' ); ?></span></a>
73
- </h3>
74
-
75
- <?php if ( $active_tab == 'pending_users' ) : ?>
76
- <div id="pw_pending_users">
77
- <?php $this->user_table( 'pending' ); ?>
78
- </div>
79
- <?php elseif ( $active_tab == 'approved_users' ) : ?>
80
- <div id="pw_approved_users">
81
- <?php $this->user_table( 'approved' ); ?>
82
- </div>
83
- <?php
84
- elseif ( $active_tab == 'denied_users' ) : ?>
85
- <div id="pw_denied_users">
86
- <?php $this->user_table( 'denied' ); ?>
87
- </div>
88
- <?php endif; ?>
89
- </div>
90
- <?php
91
  }
92
 
93
  /**
@@ -241,6 +215,55 @@ class pw_new_user_approve_admin_approve {
241
  add_user_meta( $user_id, 'pw_new_user_approve_ignore_notice', '1', true );
242
  }
243
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
 
246
  function pw_new_user_approve_admin_approve() {
34
  add_action( 'admin_init', array( $this, 'process_input' ) );
35
  add_action( 'admin_notices', array( $this, 'admin_notice' ) );
36
  add_action( 'admin_init', array( $this, 'notice_ignore' ) );
37
+ add_action( 'admin_init', array( $this, 'add_meta_boxes' ) );
38
  }
39
 
40
  /**
47
 
48
  if ( $show_admin_page ) {
49
  $cap = apply_filters( 'new_user_approve_minimum_cap', 'edit_users' );
50
+ $hook = add_users_page( __( 'Approve New Users', 'new-user-approve' ), __( 'Approve New Users', 'new-user-approve' ), $cap, $this->_admin_page, array( $this, 'approve_admin' ) );
51
+
52
+ add_action( 'load-' . $hook, array( $this, 'admin_enqueue_scripts' ) );
53
  }
54
  }
55
 
57
  * Create the view for the admin interface
58
  */
59
  public function approve_admin() {
60
+ if ( !current_user_can( 'manage_options' ) ) {
61
+ wp_die( __('You do not have sufficient permissions to access this page.') );
62
  }
63
 
64
+ require_once( pw_new_user_approve()->get_plugin_dir() . '/admin/templates/approve.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
  /**
215
  add_user_meta( $user_id, 'pw_new_user_approve_ignore_notice', '1', true );
216
  }
217
  }
218
+
219
+ public function admin_enqueue_scripts() {
220
+ wp_enqueue_script( 'post' );
221
+ }
222
+
223
+ public function add_meta_boxes() {
224
+ add_meta_box( 'nua-approve-admin', __( 'Approve Users', 'new-user-approve' ), array( $this, 'metabox_main' ), 'users_page_new-user-approve-admin', 'main', 'high' );
225
+ add_meta_box( 'nua-updates', __( 'Updates', 'new-user-approve' ), array( $this, 'metabox_ajax' ), 'users_page_new-user-approve-admin', 'side', 'default', array( 'url' => 'http://newuserapprove.com/wp-json/posts/52' ) );
226
+ add_meta_box( 'nua-support', __( 'Support', 'new-user-approve' ), array( $this, 'metabox_ajax' ), 'users_page_new-user-approve-admin', 'side', 'default', array( 'url' => 'http://newuserapprove.com/wp-json/posts/54' ) );
227
+ add_meta_box( 'nua-feedback', __( 'Feedback', 'new-user-approve' ), array( $this, 'metabox_ajax' ), 'users_page_new-user-approve-admin', 'side', 'default', array( 'url' => 'http://newuserapprove.com/wp-json/posts/56' ) );
228
+ }
229
+
230
+ public function metabox_main() {
231
+ $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'pending_users';
232
+ ?>
233
+ <h3 class="nav-tab-wrapper" style="padding-bottom: 0; border-bottom: none;">
234
+ <a href="<?php echo esc_url( admin_url( 'users.php?page=new-user-approve-admin&tab=pending_users' ) ); ?>"
235
+ class="nav-tab<?php echo $active_tab == 'pending_users' ? ' nav-tab-active' : ''; ?>"><span><?php _e( 'Users Pending Approval', 'new-user-approve' ); ?></span></a>
236
+ <a href="<?php echo esc_url( admin_url( 'users.php?page=new-user-approve-admin&tab=approved_users' ) ); ?>"
237
+ class="nav-tab<?php echo $active_tab == 'approved_users' ? ' nav-tab-active' : ''; ?>"><span><?php _e( 'Approved Users', 'new-user-approve' ); ?></span></a>
238
+ <a href="<?php echo esc_url( admin_url( 'users.php?page=new-user-approve-admin&tab=denied_users' ) ); ?>"
239
+ class="nav-tab<?php echo $active_tab == 'denied_users' ? ' nav-tab-active' : ''; ?>"><span><?php _e( 'Denied Users', 'new-user-approve' ); ?></span></a>
240
+ </h3>
241
+
242
+ <?php if ( $active_tab == 'pending_users' ) : ?>
243
+ <div id="pw_pending_users">
244
+ <?php $this->user_table( 'pending' ); ?>
245
+ </div>
246
+ <?php elseif ( $active_tab == 'approved_users' ) : ?>
247
+ <div id="pw_approved_users">
248
+ <?php $this->user_table( 'approved' ); ?>
249
+ </div>
250
+ <?php
251
+ elseif ( $active_tab == 'denied_users' ) : ?>
252
+ <div id="pw_denied_users">
253
+ <?php $this->user_table( 'denied' ); ?>
254
+ </div>
255
+ <?php endif;
256
+ }
257
+
258
+ public function metabox_ajax( $post, $metabox = array() ) {
259
+ $response = wp_remote_get( $metabox['args']['url'] );
260
+ if ( wp_remote_retrieve_response_code( $response ) == 200 ) {
261
+ $body = wp_remote_retrieve_body( $response );
262
+ $details = json_decode( $body );
263
+ print $details->content;
264
+ }
265
+ }
266
+
267
  }
268
 
269
  function pw_new_user_approve_admin_approve() {
includes/user-list.php CHANGED
@@ -48,7 +48,7 @@ class pw_new_user_approve_user_list {
48
  if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'approve', 'deny' ) ) && !isset( $_GET['new_role'] ) ) {
49
  check_admin_referer( 'new-user-approve' );
50
 
51
- $sendback = remove_query_arg( array( 'approved', 'denied', 'deleted', 'ids', 'new_user_approve_filter', 'pw-status-query-submit', 'new_role' ), wp_get_referer() );
52
  if ( !$sendback )
53
  $sendback = admin_url( 'users.php' );
54
 
@@ -86,8 +86,13 @@ class pw_new_user_approve_user_list {
86
 
87
  $user_status = pw_new_user_approve()->get_user_status( $user->ID );
88
 
89
- $approve_link = wp_nonce_url( add_query_arg( array( 'action' => 'approve', 'user' => $user->ID ) ), 'new-user-approve' );
90
- $deny_link = wp_nonce_url( add_query_arg( array( 'action' => 'deny', 'user' => $user->ID ) ), 'new-user-approve' );
 
 
 
 
 
91
 
92
  $approve_action = '<a href="' . esc_url( $approve_link ) . '">' . __( 'Approve', 'new-user-approve' ) . '</a>';
93
  $deny_action = '<a href="' . esc_url( $deny_link ) . '">' . __( 'Deny', 'new-user-approve' ) . '</a>';
48
  if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'approve', 'deny' ) ) && !isset( $_GET['new_role'] ) ) {
49
  check_admin_referer( 'new-user-approve' );
50
 
51
+ $sendback = remove_query_arg( array( 'approved', 'denied', 'deleted', 'ids', 'pw-status-query-submit', 'new_role' ), wp_get_referer() );
52
  if ( !$sendback )
53
  $sendback = admin_url( 'users.php' );
54
 
86
 
87
  $user_status = pw_new_user_approve()->get_user_status( $user->ID );
88
 
89
+ $approve_link = add_query_arg( array( 'action' => 'approve', 'user' => $user->ID ) );
90
+ $approve_link = remove_query_arg( array( 'new_role' ), $approve_link );
91
+ $approve_link = wp_nonce_url( $approve_link, 'new-user-approve' );
92
+
93
+ $deny_link = add_query_arg( array( 'action' => 'deny', 'user' => $user->ID ) );
94
+ $deny_link = remove_query_arg( array( 'new_role' ), $deny_link );
95
+ $deny_link = wp_nonce_url( $deny_link, 'new-user-approve' );
96
 
97
  $approve_action = '<a href="' . esc_url( $approve_link ) . '">' . __( 'Approve', 'new-user-approve' ) . '</a>';
98
  $deny_action = '<a href="' . esc_url( $deny_link ) . '">' . __( 'Deny', 'new-user-approve' ) . '</a>';
localization/new-user-approve-fr_FR.mo DELETED
Binary file
localization/new-user-approve-fr_FR.po DELETED
@@ -1,193 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: New User Approve 1.0\n"
4
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/new-user-approve\n"
5
- "POT-Creation-Date: 2009-10-29 08:32+0000\n"
6
- "PO-Revision-Date: 2012-06-18 22:39+0100\n"
7
- "Last-Translator: Josh Harrison <josh@picklewagon.com>\n"
8
- "Language-Team: Philippe Scoffoni <philippe@scoffoni.net>\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-Language: French\n"
13
-
14
- #: new-user-approve.php:126
15
- msgid "Approve New Users"
16
- msgstr "Approuver les utilisateurs"
17
-
18
- #: new-user-approve.php:140
19
- msgid "Settings"
20
- msgstr "Param&#232;tres"
21
-
22
- #: new-user-approve.php:183
23
- msgid "Users"
24
- msgstr "Utilisateurs"
25
-
26
- #: new-user-approve.php:219
27
- msgid "User successfully updated."
28
- msgstr "Utilisateur mis &#224; jour avec succ&#232;s"
29
-
30
- #: new-user-approve.php:223
31
- msgid "User Registration Approval"
32
- msgstr "Approbation de l'inscription de l'utilisateur"
33
-
34
- #: new-user-approve.php:225
35
- msgid "User Management"
36
- msgstr "Gestion des utilisateurs"
37
-
38
- #: new-user-approve.php:228
39
- msgid "Users Pending Approval"
40
- msgstr "Utilisateurs en attente d'approbation"
41
-
42
- #: new-user-approve.php:229
43
- msgid "Approved Users"
44
- msgstr "Utilisateurs approuv&#233;s"
45
-
46
- #: new-user-approve.php:230
47
- msgid "Denied Users"
48
- msgstr "Utilisateurs refus&#233;s"
49
-
50
- #: new-user-approve.php:255
51
- msgid "ID"
52
- msgstr "ID"
53
-
54
- #: new-user-approve.php:256
55
- msgid "Username"
56
- msgstr "Nom de compte"
57
-
58
- #: new-user-approve.php:257
59
- msgid "Name"
60
- msgstr "Nom"
61
-
62
- #: new-user-approve.php:258
63
- msgid "E-mail"
64
- msgstr "E-mail"
65
-
66
- #: new-user-approve.php:260
67
- #: new-user-approve.php:262
68
- msgid "Actions"
69
- msgstr "Actions"
70
-
71
- #: new-user-approve.php:296
72
- msgid "email:"
73
- msgstr "email"
74
-
75
- #: new-user-approve.php:298
76
- msgid "Approve"
77
- msgstr "Approuver"
78
-
79
- #: new-user-approve.php:301
80
- msgid "Deny"
81
- msgstr "Refuser"
82
-
83
- #: new-user-approve.php:313
84
- msgid "approved"
85
- msgstr "approuv&#233;"
86
-
87
- #: new-user-approve.php:315
88
- msgid "denied"
89
- msgstr "refus&#233;"
90
-
91
- #: new-user-approve.php:317
92
- msgid "pending"
93
- msgstr "en attente"
94
-
95
- #: new-user-approve.php:320
96
- #, php-format
97
- msgid "There are no users with a status of %s"
98
- msgstr "Il n'y a aucun utilisateur avec le status %s"
99
-
100
- #: new-user-approve.php:332
101
- msgid "User name already exists"
102
- msgstr "Nom d'utilisateur d&#233;j&#224; existant"
103
-
104
- #: new-user-approve.php:335
105
- #, php-format
106
- msgid "%1$s (%2$s) has requested a username at %3$s"
107
- msgstr "%1$s (%2$s) a demand&#233; l'approbation d'un compte sur %3$s"
108
-
109
- #: new-user-approve.php:337
110
- #, php-format
111
- msgid "To approve or deny this user access to %s go to"
112
- msgstr "Pour approuver ou refuser cet utilisateur, aller sur le site %s"
113
-
114
- #: new-user-approve.php:341
115
- #, php-format
116
- msgid "[%s] User Approval"
117
- msgstr "[%s] Demande d'approbation pour un utilisateur"
118
-
119
- #: new-user-approve.php:372
120
- #, php-format
121
- msgid "You have been approved to access %s"
122
- msgstr "Votre inscription a &#233;t&#233; accept&#233;e pour acc&#233;der au site %s"
123
-
124
- #: new-user-approve.php:373
125
- #, php-format
126
- msgid "Username: %s"
127
- msgstr "Nom de compte : %s"
128
-
129
- #: new-user-approve.php:374
130
- #, php-format
131
- msgid "Password: %s"
132
- msgstr "Mot de passe : %s"
133
-
134
- #: new-user-approve.php:378
135
- #, php-format
136
- msgid "[%s] Registration Approved"
137
- msgstr "[%s] Inscription approuv&#233;e"
138
-
139
- #: new-user-approve.php:397
140
- #, php-format
141
- msgid "You have been denied access to %s"
142
- msgstr "Votre inscription a &#233;t&#233; refus&#233;e pour acc&#233;der au site %s"
143
-
144
- #: new-user-approve.php:400
145
- #, php-format
146
- msgid "[%s] Registration Denied"
147
- msgstr "[%s] Inscription refus&#233;e"
148
-
149
- #: new-user-approve.php:413
150
- msgid "An email has been sent to the site administrator. The administrator will review the information that has been submitted and either approve or deny your request."
151
- msgstr "Un email a &#233;t&#233; envoy&#233; &#224; l'administrateur du site. Il va v&#233;rifier les informations que vous avez transmises et approuver ou refuser votre demande d'inscription. "
152
-
153
- #: new-user-approve.php:414
154
- msgid "You will receive an email with instructions on what you will need to do next. Thanks for your patience."
155
- msgstr "Vous allez recevoir un email avec les instructions sur ce que vous devez ensuite faire. Merci de votre patience."
156
-
157
- #: new-user-approve.php:418
158
- msgid "Pending Approval"
159
- msgstr "Approbation en attente"
160
-
161
- #: new-user-approve.php:418
162
- msgid "Registration successful."
163
- msgstr "Inscription r&#233;ussie"
164
-
165
- #: new-user-approve.php:466
166
- #, php-format
167
- msgid "Welcome to %s. This site is accessible to approved users only. To be approved, you must first register."
168
- msgstr "Bienvenue sur le site %s. Ce site est accessible aux utilisateurs approuv&#233;s. Pour &#234;tre approuv&#233;, vous devez d'abord vous inscrire."
169
-
170
- #: new-user-approve.php:471
171
- msgid "After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions."
172
- msgstr "Apr&#232;s l'inscription, votre demande sera envoy&#233;e &#224; l'administrateur pour approbation. Vous recevrez alors un email avec plus d'informations."
173
-
174
- #. Plugin Name of an extension
175
- msgid "New User Approve"
176
- msgstr "Nouvel utilisateur approuv&#233;"
177
-
178
- #. Plugin URI of an extension
179
- msgid "http://www.picklewagon.com/wordpress/new-user-approve"
180
- msgstr "http://www.picklewagon.com/wordpress/new-user-approve"
181
-
182
- #. Description of an extension
183
- msgid "This plugin allows administrators to approve users once they register. Only approved users will be allowed to access the blog."
184
- msgstr "This plugin allows administrators to approve users once they register. Only approved users will be allowed to access the blog."
185
-
186
- #. Author of an extension
187
- msgid "Josh Harrison"
188
- msgstr "Josh Harrison"
189
-
190
- #. Author URI of an extension
191
- msgid "http://www.picklewagon.com/"
192
- msgstr "http://www.picklewagon.com/"
193
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
new-user-approve.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin URI: http://www.picklewagon.com/wordpress/new-user-approve/
5
  Description: Allow administrators to approve users once they register. Only approved users will be allowed to access the blog. For support, please go to the <a href="http://wordpress.org/support/plugin/new-user-approve">support forums</a> on wordpress.org.
6
  Author: Josh Harrison
7
- Version: 1.5.8
8
  Author URI: http://picklewagon.com/
9
  */
10
 
@@ -50,12 +50,15 @@ class pw_new_user_approve {
50
  add_action( 'user_register', array( $this, 'add_user_status' ) );
51
  add_action( 'new_user_approve_approve_user', array( $this, 'approve_user' ) );
52
  add_action( 'new_user_approve_deny_user', array( $this, 'deny_user' ) );
 
 
53
 
54
  // Filters
55
  add_filter( 'wp_authenticate_user', array( $this, 'authenticate_user' ) );
56
  add_filter( 'registration_errors', array( $this, 'show_user_pending_message' ) );
57
  add_filter( 'login_message', array( $this, 'welcome_user' ) );
58
  add_filter( 'new_user_approve_validate_status_update', array( $this, 'validate_status_update' ), 10, 3 );
 
59
  }
60
 
61
  public function get_plugin_url() {
@@ -91,6 +94,37 @@ class pw_new_user_approve {
91
  do_action( 'new_user_approve_deactivate' );
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  /**
95
  * Makes it possible to disable the user admin integration. Must happen after
96
  * WordPress is loaded.
@@ -130,25 +164,29 @@ class pw_new_user_approve {
130
  *
131
  * @param int $user
132
  * @param string $status
 
 
133
  */
134
  public function update_user_status( $user, $status ) {
135
  $user_id = absint( $user );
136
  if ( !$user_id ) {
137
- return;
138
  }
139
 
140
  if ( !in_array( $status, array( 'approve', 'deny' ) ) ) {
141
- return;
142
  }
143
 
144
  $do_update = apply_filters( 'new_user_approve_validate_status_update', true, $user_id, $status );
145
  if ( !$do_update ) {
146
- return;
147
  }
148
 
149
  // where it all happens
150
  do_action( 'new_user_approve_' . $status . '_user', $user_id );
151
  do_action( 'new_user_approve_user_status_update', $user_id, $status );
 
 
152
  }
153
 
154
  /**
@@ -184,6 +222,28 @@ class pw_new_user_approve {
184
  return $do_update;
185
  }
186
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  /**
188
  * Determine if the user is good to sign in based on their status.
189
  *
@@ -201,15 +261,11 @@ class pw_new_user_approve {
201
  $message = false;
202
  switch ( $status ) {
203
  case 'pending':
204
- $pending_message = __( '<strong>ERROR</strong>: Your account is still pending approval.', 'new-user-approve' );
205
- $pending_message = apply_filters( 'new_user_approve_pending_error', $pending_message );
206
-
207
  $message = new WP_Error( 'pending_approval', $pending_message );
208
  break;
209
  case 'denied':
210
- $denied_message = __( '<strong>ERROR</strong>: Your account has been denied access to this site.', 'new-user-approve' );
211
- $denied_message = apply_filters( 'new_user_approve_denied_error', $denied_message );
212
-
213
  $message = new WP_Error( 'denied_access', $denied_message );
214
  break;
215
  case 'approved':
@@ -220,39 +276,42 @@ class pw_new_user_approve {
220
  return $message;
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  /**
224
  * Get a status of all the users and save them using a transient
225
  */
226
  public function get_user_statuses() {
227
- $valid_stati = $this->get_valid_statuses();
228
- $user_status = get_transient( 'new_user_approve_user_statuses' );
229
 
230
- if ( false === $user_status ) {
231
- $user_status = array();
232
-
233
- foreach ( $valid_stati as $status ) {
234
- // Query the users table
235
- if ( $status != 'approved' ) {
236
- // Query the users table
237
- $query = array( 'meta_key' => 'pw_user_status', 'meta_value' => $status, );
238
- $wp_user_search = new WP_User_Query( $query );
239
- } else {
240
- // get all approved users and any user without a status
241
- $query = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'pw_user_status', 'value' => 'approved', 'compare' => '=' ), array( 'key' => 'pw_user_status', 'value' => '', 'compare' => 'NOT EXISTS' ), ), );
242
- $wp_user_search = new WP_User_Query( $query );
243
- }
244
-
245
- $user_status[$status] = $wp_user_search->get_results();
246
- }
247
-
248
- set_transient( 'new_user_approve_user_statuses', $user_status );
249
  }
250
 
251
- foreach ( $valid_stati as $status ) {
252
- $user_status[$status] = apply_filters( 'new_user_approve_user_status', $user_status[$status], $status );
253
  }
254
 
255
- return $user_status;
256
  }
257
 
258
  /**
@@ -328,7 +387,7 @@ class pw_new_user_approve {
328
  $message = str_replace( 'USERNAME', $user_login, $message );
329
  $message = str_replace( 'USEREMAIL', $user_email, $message );
330
  $message = str_replace( 'SITENAME', $blogname, $message );
331
- $message = str_replace( 'SITEURL', get_option( 'siteurl' ), $message );
332
  $message = str_replace( 'ADMINURL', $admin_url, $message );
333
 
334
  $message = apply_filters( 'new_user_approve_request_approval_message', $message, $user_login, $user_email );
@@ -340,7 +399,7 @@ class pw_new_user_approve {
340
  $to = array_unique( $to );
341
 
342
  // send the mail
343
- wp_mail( $to, $subject, $message, $this->email_message_headers() );
344
  }
345
 
346
  /**
@@ -429,12 +488,18 @@ class pw_new_user_approve {
429
  $user_email = stripslashes( $user->data->user_email );
430
 
431
  // format the message
432
- $message = sprintf( __( 'You have been approved to access %s', 'new-user-approve' ), get_option( 'blogname' ) ) . "\r\n";
433
- $message .= sprintf( __( 'Username: %s', 'new-user-approve' ), $user_login ) . "\r\n";
 
434
  if ( !$bypass_password_reset ) {
435
- $message .= sprintf( __( 'Password: %s', 'new-user-approve' ), $new_pass ) . "\r\n";
 
 
436
  }
437
- $message .= wp_login_url() . "\r\n";
 
 
 
438
 
439
  $message = apply_filters( 'new_user_approve_approve_user_message', $message, $user );
440
 
@@ -450,8 +515,23 @@ class pw_new_user_approve {
450
  do_action( 'new_user_approve_user_approved', $user );
451
  }
452
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  /**
454
- * Admin denial of user
455
  *
456
  * @uses new_user_approve_deny_user
457
  */
@@ -462,7 +542,7 @@ class pw_new_user_approve {
462
  $user_email = stripslashes( $user->user_email );
463
 
464
  // format the message
465
- $message = sprintf( __( 'You have been denied access to %s', 'new-user-approve' ), get_option( 'blogname' ) );
466
  $message = apply_filters( 'new_user_approve_deny_user_message', $message, $user );
467
 
468
  $subject = sprintf( __( '[%s] Registration Denied', 'new-user-approve' ), get_option( 'blogname' ) );
@@ -470,6 +550,15 @@ class pw_new_user_approve {
470
 
471
  // send the mail
472
  @wp_mail( $user_email, $subject, $message, $this->email_message_headers() );
 
 
 
 
 
 
 
 
 
473
 
474
  // change usermeta tag in database to denied
475
  update_user_meta( $user->ID, 'pw_user_status', 'denied' );
@@ -495,6 +584,14 @@ class pw_new_user_approve {
495
  return $headers;
496
  }
497
 
 
 
 
 
 
 
 
 
498
  /**
499
  * Display a message to the user after they have registered
500
  *
@@ -512,9 +609,7 @@ class pw_new_user_approve {
512
  return $errors;
513
  }
514
 
515
- $message = sprintf( __( 'An email has been sent to the site administrator. The administrator will review the information that has been submitted and either approve or deny your request.', 'new-user-approve' ) );
516
- $message .= ' ';
517
- $message .= sprintf( __( 'You will receive an email with instructions on what you will need to do next. Thanks for your patience.', 'new-user-approve' ) );
518
  $message = apply_filters( 'new_user_approve_pending_message', $message );
519
 
520
  $errors->add( 'registration_required', $message, 'message' );
@@ -550,6 +645,18 @@ class pw_new_user_approve {
550
  }
551
  }
552
 
 
 
 
 
 
 
 
 
 
 
 
 
553
  /**
554
  * Add message to login page saying registration is required.
555
  *
@@ -559,16 +666,18 @@ class pw_new_user_approve {
559
  */
560
  public function welcome_user( $message ) {
561
  if ( !isset( $_GET['action'] ) ) {
562
- $welcome = sprintf( __( 'Welcome to %s. This site is accessible to approved users only. To be approved, you must first register.', 'new-user-approve' ), get_option( 'blogname' ) );
563
  $welcome = apply_filters( 'new_user_approve_welcome_message', $welcome );
564
 
 
 
565
  if ( !empty( $welcome ) ) {
566
  $message .= '<p class="message register">' . $welcome . '</p>';
567
  }
568
  }
569
 
570
  if ( isset( $_GET['action'] ) && $_GET['action'] == 'register' && !$_POST ) {
571
- $instructions = sprintf( __( 'After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions.', 'new-user-approve' ) );
572
  $instructions = apply_filters( 'new_user_approve_register_instructions', $instructions );
573
 
574
  if ( !empty( $instructions ) ) {
@@ -594,6 +703,20 @@ class pw_new_user_approve {
594
  }
595
  update_user_meta( $user_id, 'pw_user_status', $status );
596
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  } // End Class
598
 
599
  function pw_new_user_approve() {
4
  Plugin URI: http://www.picklewagon.com/wordpress/new-user-approve/
5
  Description: Allow administrators to approve users once they register. Only approved users will be allowed to access the blog. For support, please go to the <a href="http://wordpress.org/support/plugin/new-user-approve">support forums</a> on wordpress.org.
6
  Author: Josh Harrison
7
+ Version: 1.6
8
  Author URI: http://picklewagon.com/
9
  */
10
 
50
  add_action( 'user_register', array( $this, 'add_user_status' ) );
51
  add_action( 'new_user_approve_approve_user', array( $this, 'approve_user' ) );
52
  add_action( 'new_user_approve_deny_user', array( $this, 'deny_user' ) );
53
+ add_action( 'new_user_approve_deny_user', array( $this, 'update_deny_status' ) );
54
+ add_action( 'admin_init', array( $this, 'verify_settings' ) );
55
 
56
  // Filters
57
  add_filter( 'wp_authenticate_user', array( $this, 'authenticate_user' ) );
58
  add_filter( 'registration_errors', array( $this, 'show_user_pending_message' ) );
59
  add_filter( 'login_message', array( $this, 'welcome_user' ) );
60
  add_filter( 'new_user_approve_validate_status_update', array( $this, 'validate_status_update' ), 10, 3 );
61
+ add_filter( 'shake_error_codes', array( $this, 'failure_shake' ) );
62
  }
63
 
64
  public function get_plugin_url() {
94
  do_action( 'new_user_approve_deactivate' );
95
  }
96
 
97
+ /**
98
+ * Verify settings upon activation
99
+ *
100
+ * @uses admin_init
101
+ */
102
+ public function verify_settings() {
103
+ // make sure the membership setting is turned on
104
+ if ( get_option( 'users_can_register' ) != 1 ) {
105
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Show admin notice if the membership setting is turned off.
111
+ */
112
+ public function admin_notices() {
113
+ $user_id = get_current_user_id();
114
+
115
+ // update the setting for the current user
116
+ if ( isset( $_GET['new-user-approve-settings-notice'] ) && '1' == $_GET['new-user-approve-settings-notice'] ) {
117
+ add_user_meta( $user_id, 'pw_new_user_approve_settings_notice', '1', true );
118
+ }
119
+
120
+ // Check that the user hasn't already clicked to ignore the message
121
+ if ( !get_user_meta( $user_id, 'pw_new_user_approve_settings_notice' ) ) {
122
+ echo '<div class="error"><p>';
123
+ printf( __( 'The Membership setting must be turned on in order for the New User Approve to work correctly. <a href="%1$s">Update in settings</a>. | <a href="%2$s">Hide Notice</a>', 'new-user-approve' ), admin_url( 'options-general.php' ), add_query_arg( array( 'new-user-approve-settings-notice' => 1 ) ) );
124
+ echo "</p></div>";
125
+ }
126
+ }
127
+
128
  /**
129
  * Makes it possible to disable the user admin integration. Must happen after
130
  * WordPress is loaded.
164
  *
165
  * @param int $user
166
  * @param string $status
167
+ *
168
+ * @return boolean
169
  */
170
  public function update_user_status( $user, $status ) {
171
  $user_id = absint( $user );
172
  if ( !$user_id ) {
173
+ return false;
174
  }
175
 
176
  if ( !in_array( $status, array( 'approve', 'deny' ) ) ) {
177
+ return false;
178
  }
179
 
180
  $do_update = apply_filters( 'new_user_approve_validate_status_update', true, $user_id, $status );
181
  if ( !$do_update ) {
182
+ return false;
183
  }
184
 
185
  // where it all happens
186
  do_action( 'new_user_approve_' . $status . '_user', $user_id );
187
  do_action( 'new_user_approve_user_status_update', $user_id, $status );
188
+
189
+ return true;
190
  }
191
 
192
  /**
222
  return $do_update;
223
  }
224
 
225
+ /**
226
+ * The default message that is shown to a user depending on their status
227
+ * when trying to sign in.
228
+ *
229
+ * @return string
230
+ */
231
+ public function default_authentication_message( $status ) {
232
+ $message = '';
233
+
234
+ if ( $status == 'pending' ) {
235
+ $message = __( '<strong>ERROR</strong>: Your account is still pending approval.', 'new-user-approve' );
236
+ $message = apply_filters( 'new_user_approve_pending_error', $message );
237
+ } else if ( $status == 'denied' ) {
238
+ $message = __( '<strong>ERROR</strong>: Your account has been denied access to this site.', 'new-user-approve' );
239
+ $message = apply_filters( 'new_user_approve_denied_error', $message );
240
+ }
241
+
242
+ $message = apply_filters( 'new_user_approve_default_authentication_message', $message, $status );
243
+
244
+ return $message;
245
+ }
246
+
247
  /**
248
  * Determine if the user is good to sign in based on their status.
249
  *
261
  $message = false;
262
  switch ( $status ) {
263
  case 'pending':
264
+ $pending_message = $this->default_authentication_message( 'pending' );
 
 
265
  $message = new WP_Error( 'pending_approval', $pending_message );
266
  break;
267
  case 'denied':
268
+ $denied_message = $this->default_authentication_message( 'denied' );
 
 
269
  $message = new WP_Error( 'denied_access', $denied_message );
270
  break;
271
  case 'approved':
276
  return $message;
277
  }
278
 
279
+ public function _get_user_statuses() {
280
+ $statuses = array();
281
+
282
+ foreach ( $this->get_valid_statuses() as $status ) {
283
+ // Query the users table
284
+ if ( $status != 'approved' ) {
285
+ // Query the users table
286
+ $query = array( 'meta_key' => 'pw_user_status', 'meta_value' => $status, );
287
+ $wp_user_search = new WP_User_Query( $query );
288
+ } else {
289
+ // get all approved users and any user without a status
290
+ $query = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'pw_user_status', 'value' => 'approved', 'compare' => '=' ), array( 'key' => 'pw_user_status', 'value' => '', 'compare' => 'NOT EXISTS' ), ), );
291
+ $wp_user_search = new WP_User_Query( $query );
292
+ }
293
+
294
+ $statuses[$status] = $wp_user_search->get_results();
295
+ }
296
+
297
+ return $statuses;
298
+ }
299
  /**
300
  * Get a status of all the users and save them using a transient
301
  */
302
  public function get_user_statuses() {
303
+ $user_statuses = get_transient( 'new_user_approve_user_statuses' );
 
304
 
305
+ if ( false === $user_statuses ) {
306
+ $user_statuses = $this->_get_user_statuses();
307
+ set_transient( 'new_user_approve_user_statuses', $user_statuses );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  }
309
 
310
+ foreach ( $this->get_valid_statuses() as $status ) {
311
+ $user_statuses[$status] = apply_filters( 'new_user_approve_user_status', $user_statuses[$status], $status );
312
  }
313
 
314
+ return $user_statuses;
315
  }
316
 
317
  /**
387
  $message = str_replace( 'USERNAME', $user_login, $message );
388
  $message = str_replace( 'USEREMAIL', $user_email, $message );
389
  $message = str_replace( 'SITENAME', $blogname, $message );
390
+ $message = str_replace( 'SITEURL', home_url(), $message );
391
  $message = str_replace( 'ADMINURL', $admin_url, $message );
392
 
393
  $message = apply_filters( 'new_user_approve_request_approval_message', $message, $user_login, $user_email );
399
  $to = array_unique( $to );
400
 
401
  // send the mail
402
+ $send = wp_mail( $to, $subject, $message, $this->email_message_headers() );
403
  }
404
 
405
  /**
488
  $user_email = stripslashes( $user->data->user_email );
489
 
490
  // format the message
491
+ $message = apply_filters( 'new_user_approve_approve_user_message_default', $this->default_approve_user_message() );
492
+
493
+ $message = str_replace( 'USERNAME', sprintf( __( 'Username: %s', 'new-user-approve' ), $user_login ), $message );
494
  if ( !$bypass_password_reset ) {
495
+ $message = str_replace( 'PASSWORD', sprintf( __( 'Password: %s', 'new-user-approve' ), $new_pass ), $message );
496
+ } else {
497
+ $message = str_replace( 'PASSWORD', '', $message );
498
  }
499
+ $message = str_replace( 'USEREMAIL', $user_email, $message );
500
+ $message = str_replace( 'SITENAME', get_option( 'blogname' ), $message );
501
+ $message = str_replace( 'SITEURL', home_url(), $message );
502
+ $message = str_replace( 'LOGINURL', wp_login_url(), $message );
503
 
504
  $message = apply_filters( 'new_user_approve_approve_user_message', $message, $user );
505
 
515
  do_action( 'new_user_approve_user_approved', $user );
516
  }
517
 
518
+ public function default_approve_user_message() {
519
+ $message = __( 'You have been approved to access SITENAME', 'new-user-approve' ) . "\r\n\r\n";
520
+ $message .= "USERNAME\r\n";
521
+ $message .= "PASSWORD\r\n\r\n";
522
+ $message .= "LOGINURL";
523
+
524
+ return $message;
525
+ }
526
+
527
+ public function default_deny_user_message() {
528
+ $message = sprintf( __( 'You have been denied access to %s.', 'new-user-approve' ), get_option( 'blogname' ) );
529
+
530
+ return $message;
531
+ }
532
+
533
  /**
534
+ * Send email to notify user of denial.
535
  *
536
  * @uses new_user_approve_deny_user
537
  */
542
  $user_email = stripslashes( $user->user_email );
543
 
544
  // format the message
545
+ $message = $this->default_deny_user_message();
546
  $message = apply_filters( 'new_user_approve_deny_user_message', $message, $user );
547
 
548
  $subject = sprintf( __( '[%s] Registration Denied', 'new-user-approve' ), get_option( 'blogname' ) );
550
 
551
  // send the mail
552
  @wp_mail( $user_email, $subject, $message, $this->email_message_headers() );
553
+ }
554
+
555
+ /**
556
+ * Update user status when denying user.
557
+ *
558
+ * @uses new_user_approve_deny_user
559
+ */
560
+ public function update_deny_status( $user_id ) {
561
+ $user = new WP_User( $user_id );
562
 
563
  // change usermeta tag in database to denied
564
  update_user_meta( $user->ID, 'pw_user_status', 'denied' );
584
  return $headers;
585
  }
586
 
587
+ public function default_registration_complete_message() {
588
+ $message = sprintf( __( 'An email has been sent to the site administrator. The administrator will review the information that has been submitted and either approve or deny your request.', 'new-user-approve' ) );
589
+ $message .= ' ';
590
+ $message .= sprintf( __( 'You will receive an email with instructions on what you will need to do next. Thanks for your patience.', 'new-user-approve' ) );
591
+
592
+ return $message;
593
+ }
594
+
595
  /**
596
  * Display a message to the user after they have registered
597
  *
609
  return $errors;
610
  }
611
 
612
+ $message = $this->default_registration_complete_message();
 
 
613
  $message = apply_filters( 'new_user_approve_pending_message', $message );
614
 
615
  $errors->add( 'registration_required', $message, 'message' );
645
  }
646
  }
647
 
648
+ public function default_welcome_message() {
649
+ $welcome = sprintf( __( 'Welcome to SITENAME. This site is accessible to approved users only. To be approved, you must first register.', 'new-user-approve' ), get_option( 'blogname' ) );
650
+ $welcome = apply_filters( 'new_user_approve_welcome_message_default', $welcome );
651
+
652
+ return $welcome;
653
+ }
654
+
655
+ public function default_registration_message() {
656
+ $message = __( 'After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions.', 'new-user-approve' );
657
+
658
+ return $message;
659
+ }
660
  /**
661
  * Add message to login page saying registration is required.
662
  *
666
  */
667
  public function welcome_user( $message ) {
668
  if ( !isset( $_GET['action'] ) ) {
669
+ $welcome = $this->default_welcome_message();
670
  $welcome = apply_filters( 'new_user_approve_welcome_message', $welcome );
671
 
672
+ $welcome = str_replace( 'SITENAME', get_option( 'blogname' ), $welcome );
673
+
674
  if ( !empty( $welcome ) ) {
675
  $message .= '<p class="message register">' . $welcome . '</p>';
676
  }
677
  }
678
 
679
  if ( isset( $_GET['action'] ) && $_GET['action'] == 'register' && !$_POST ) {
680
+ $instructions = $this->default_registration_message();
681
  $instructions = apply_filters( 'new_user_approve_register_instructions', $instructions );
682
 
683
  if ( !empty( $instructions ) ) {
703
  }
704
  update_user_meta( $user_id, 'pw_user_status', $status );
705
  }
706
+
707
+ /**
708
+ * Add error codes to shake the login form on failure
709
+ *
710
+ * @uses shake_error_codes
711
+ * @param $error_codes
712
+ * @return array
713
+ */
714
+ public function failure_shake( $error_codes ) {
715
+ $error_codes[] = 'pending_approval';
716
+ $error_codes[] = 'denied_access';
717
+
718
+ return $error_codes;
719
+ }
720
  } // End Class
721
 
722
  function pw_new_user_approve() {
phpunit.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <phpunit
2
+ bootstrap="tests/bootstrap.php"
3
+ backupGlobals="false"
4
+ colors="true"
5
+ convertErrorsToExceptions="true"
6
+ convertNoticesToExceptions="true"
7
+ convertWarningsToExceptions="true"
8
+ >
9
+ <testsuites>
10
+ <testsuite>
11
+ <directory prefix="test-" suffix=".php">./tests/</directory>
12
+ </testsuite>
13
+ </testsuites>
14
+ </phpunit>
readme.txt CHANGED
@@ -1,15 +1,15 @@
1
  === Plugin Name ===
2
  Contributors: picklewagon
3
  Donate link: http://picklewagon.com/wordpress/new-user-approve/donate
4
- Tags: users, registration, sign up, user management
5
  Requires at least: 3.5.1
6
- Tested up to: 3.9
7
- Stable tag: 1.5.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- New User Approve is a WordPress plugin that allows a blog administrator to
12
- approve a user before they are able to access and login to the blog.
13
 
14
  == Description ==
15
 
@@ -18,16 +18,41 @@ the database. Then an email is sent to the new user with their login
18
  credentials. Very simple. As it should be.
19
 
20
  The New User Approve plugin modifies the registration process. When a user
21
- registers for the blog, the user gets created and then an email gets sent to
22
  the administrators of the site. An administrator then is expected to either
23
  approve or deny the registration request. An email is then sent to the user
24
  indicating whether they were approved or denied. If the user has been approved,
25
  the email will include the login credentials. Until a user is approved, the
26
  user will not be able to login to the site.
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  == Installation ==
29
 
30
- 1. Upload new-user-approve to the wp-content/plugins directory
 
31
  2. Activate the plugin through the Plugins menu in WordPress
32
  3. No configuration necessary.
33
 
@@ -59,15 +84,32 @@ to retrieve the user's password.
59
  There is a filter available (new_user_approve_bypass_password_reset) to turn off
60
  this feature.
61
 
 
 
 
 
 
 
62
  == Screenshots ==
63
 
64
  1. The backend to manage approving and denying users. This is an alternative to approving users.
65
  2. Integration with WordPress Users admin page.
66
  3. Filter users by status.
67
  4. Approve or deny users using the bulk edit feature in WordPress.
 
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
 
 
 
 
 
71
  = 1.5.8 =
72
  * tested for WordPress 3.9
73
  * fix bug preventing the notice from hiding on legacy page
1
  === Plugin Name ===
2
  Contributors: picklewagon
3
  Donate link: http://picklewagon.com/wordpress/new-user-approve/donate
4
+ Tags: users, registration, sign up, user management, login
5
  Requires at least: 3.5.1
6
+ Tested up to: 3.9.1
7
+ Stable tag: 1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ New User Approve allows a site administrator to approve a user before they
12
+ are able to login to the site.
13
 
14
  == Description ==
15
 
18
  credentials. Very simple. As it should be.
19
 
20
  The New User Approve plugin modifies the registration process. When a user
21
+ registers for the site, the user gets created and then an email gets sent to
22
  the administrators of the site. An administrator then is expected to either
23
  approve or deny the registration request. An email is then sent to the user
24
  indicating whether they were approved or denied. If the user has been approved,
25
  the email will include the login credentials. Until a user is approved, the
26
  user will not be able to login to the site.
27
 
28
+ Only approved users will be allowed to login to site. Users waiting for approval
29
+ as well as denied users will not be able to login to site.
30
+
31
+ A user's status can be updated even after the initial approval/denial.
32
+
33
+ Each user that exists before New User Approve has been activated will be treated as
34
+ an approved user.
35
+
36
+ Default WordPress registration process:
37
+ 1. User registers for access to site.
38
+ 2. Login credentials is sent to new user in an email.
39
+ 3. Admin is notified of new user signup via email.
40
+ 4. User logs in to site using login credentials.
41
+
42
+ WordPress registration process with New User Approve plugin activated:
43
+ 1. User registers for access to site.
44
+ 2. User is shown message to wait for approval.
45
+ 3. Admin is notified of new user signup via email.
46
+ 4. Admin goes to admin to approve or deny new user.
47
+ 5. Email is sent to user. If approved, email will include login credentials.
48
+ 6. User logs in to site using login credentials.
49
+
50
+ [Fork New User Approve on Github](https://github.com/picklewagon/new-user-approve)
51
+
52
  == Installation ==
53
 
54
+ 1. Upload new-user-approve to the wp-content/plugins directory or download from
55
+ the WordPress backend (Plugins -> Add New -> search for 'new user approve')
56
  2. Activate the plugin through the Plugins menu in WordPress
57
  3. No configuration necessary.
58
 
84
  There is a filter available (new_user_approve_bypass_password_reset) to turn off
85
  this feature.
86
 
87
+ = What happens to the user's status after the plugin is deactivated? =
88
+
89
+ If you deactivate the plugin, their status doesn't matter. The status that the
90
+ plugin uses is only used by the plugin. All users will be allowed to login as long
91
+ as they have their username and passwords.
92
+
93
  == Screenshots ==
94
 
95
  1. The backend to manage approving and denying users. This is an alternative to approving users.
96
  2. Integration with WordPress Users admin page.
97
  3. Filter users by status.
98
  4. Approve or deny users using the bulk edit feature in WordPress.
99
+ 5. Custom messages on the login screen.
100
 
101
  == Changelog ==
102
 
103
+ = 1.6 =
104
+ * improve actions and filters
105
+ * refactor messages to make them easier to override
106
+ * show admin notice if the membership setting is turned off
107
+ * fix bug preventing approvals/denials when using filter
108
+ * add sidebar in admin to help with support
109
+ * unit tests
110
+ * shake the login form when attempting to login as unapproved user
111
+ * updated French translation
112
+
113
  = 1.5.8 =
114
  * tested for WordPress 3.9
115
  * fix bug preventing the notice from hiding on legacy page
tests/bootstrap.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php';
4
+
5
+ function _manually_load_plugin() {
6
+ require dirname( __FILE__ ) . '/../new-user-approve.php';
7
+ }
8
+ tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
9
+
10
+ require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';
11
+
tests/test-users.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NewUserApproveUserTest extends WP_UnitTestCase {
4
+
5
+ function testStatusOfNewUser() {
6
+ $user_id = $this->factory->user->create();
7
+ $status = pw_new_user_approve()->get_user_status( $user_id );
8
+
9
+ // default status for new user is pending
10
+ $this->assertEquals( $status, 'pending' );
11
+ }
12
+
13
+ function testStatusOfUserAlreadyAdded() {
14
+ $user = get_user_by( 'login', 'admin' );
15
+
16
+ $user_status = get_user_meta( $user->ID, 'pw_user_status', true );
17
+ $this->assertEmpty( $user_status );
18
+
19
+ $status = pw_new_user_approve()->get_user_status( $user->ID );
20
+ $this->assertEquals( $status, 'approved' );
21
+ }
22
+
23
+ function testStatusUpdate() {
24
+ $user_id = $this->factory->user->create();
25
+
26
+ $result = pw_new_user_approve()->update_user_status( 'hello', 'approve' );
27
+ $this->assertFalse( $result );
28
+
29
+ $result = pw_new_user_approve()->update_user_status( $user_id, 'hello' );
30
+ $this->assertFalse( $result );
31
+
32
+ $result = pw_new_user_approve()->update_user_status( $user_id, 'approve' );
33
+ $this->assertTrue( $result );
34
+
35
+ add_filter( 'new_user_approve_validate_status_update', '__return_false' );
36
+
37
+ $another_user = $this->factory->user->create();
38
+ $result = pw_new_user_approve()->update_user_status( $another_user, 'deny' );
39
+ $this->assertFalse( $result );
40
+
41
+ remove_filter( 'new_user_approve_validate_status_update', '__return_false' );
42
+
43
+ $result = pw_new_user_approve()->update_user_status( $user_id, 'deny' );
44
+ $this->assertTrue( $result );
45
+ }
46
+
47
+ function testValidStatuses() {
48
+ $statuses = pw_new_user_approve()->get_valid_statuses();
49
+
50
+ $this->assertEquals( $statuses, array( 'pending', 'approved', 'denied' ) );
51
+ }
52
+
53
+ function testStatusValidation() {
54
+ $user_id = $this->factory->user->create();
55
+
56
+ $result = pw_new_user_approve()->update_user_status( $user_id, 'approve' );
57
+ $this->assertTrue( $result );
58
+
59
+ $do_update = pw_new_user_approve()->validate_status_update( true, $user_id, 'approve' );
60
+ $this->assertFalse( $do_update );
61
+ }
62
+
63
+ function testUserStatusList() {
64
+ $valids = pw_new_user_approve()->get_valid_statuses();
65
+
66
+ $statuses = pw_new_user_approve()->_get_user_statuses();
67
+
68
+ $this->assertTrue( is_array( $statuses ) );
69
+ $this->assertEquals( count($statuses), count( $valids ) );
70
+ }
71
+ }
72
+