New User Approve - Version 1.2

Version Description

  • add localization support
  • add a changelog to readme.txt
  • remove plugin constants that have been defined since 2.6
  • correct the use of db prepare statements/use prepare on all SQL statements
  • add wp_enqueue_style for the admin style sheet
Download this release

Release Info

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

Code changes from version 1.1.3 to 1.2

localization/new-user-approve.pot ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR Josh Harrison
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/new-user-approve\n"
11
+ "POT-Creation-Date: 2009-10-29 08:32+0000\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=CHARSET\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+
19
+ #: new-user-approve.php:126
20
+ msgid "Approve New Users"
21
+ msgstr ""
22
+
23
+ #: new-user-approve.php:140
24
+ msgid "Settings"
25
+ msgstr ""
26
+
27
+ #: new-user-approve.php:183
28
+ msgid "Users"
29
+ msgstr ""
30
+
31
+ #: new-user-approve.php:219
32
+ msgid "User successfully updated."
33
+ msgstr ""
34
+
35
+ #: new-user-approve.php:223
36
+ msgid "User Registration Approval"
37
+ msgstr ""
38
+
39
+ #: new-user-approve.php:225
40
+ msgid "User Management"
41
+ msgstr ""
42
+
43
+ #: new-user-approve.php:228
44
+ msgid "Users Pending Approval"
45
+ msgstr ""
46
+
47
+ #: new-user-approve.php:229
48
+ msgid "Approved Users"
49
+ msgstr ""
50
+
51
+ #: new-user-approve.php:230
52
+ msgid "Denied Users"
53
+ msgstr ""
54
+
55
+ #: new-user-approve.php:255
56
+ msgid "ID"
57
+ msgstr ""
58
+
59
+ #: new-user-approve.php:256
60
+ msgid "Username"
61
+ msgstr ""
62
+
63
+ #: new-user-approve.php:257
64
+ msgid "Name"
65
+ msgstr ""
66
+
67
+ #: new-user-approve.php:258
68
+ msgid "E-mail"
69
+ msgstr ""
70
+
71
+ #: new-user-approve.php:260 new-user-approve.php:262
72
+ msgid "Actions"
73
+ msgstr ""
74
+
75
+ #: new-user-approve.php:296
76
+ msgid "email:"
77
+ msgstr ""
78
+
79
+ #: new-user-approve.php:298
80
+ msgid "Approve"
81
+ msgstr ""
82
+
83
+ #: new-user-approve.php:301
84
+ msgid "Deny"
85
+ msgstr ""
86
+
87
+ #: new-user-approve.php:313
88
+ msgid "approved"
89
+ msgstr ""
90
+
91
+ #: new-user-approve.php:315
92
+ msgid "denied"
93
+ msgstr ""
94
+
95
+ #: new-user-approve.php:317
96
+ msgid "pending"
97
+ msgstr ""
98
+
99
+ #: new-user-approve.php:320
100
+ #, php-format
101
+ msgid "There are no users with a status of %s"
102
+ msgstr ""
103
+
104
+ #: new-user-approve.php:332
105
+ msgid "User name already exists"
106
+ msgstr ""
107
+
108
+ #: new-user-approve.php:335
109
+ #, php-format
110
+ msgid "%1$s (%2$s) has requested a username at %3$s"
111
+ msgstr ""
112
+
113
+ #: new-user-approve.php:337
114
+ #, php-format
115
+ msgid "To approve or deny this user access to %s go to"
116
+ msgstr ""
117
+
118
+ #: new-user-approve.php:341
119
+ #, php-format
120
+ msgid "[%s] User Approval"
121
+ msgstr ""
122
+
123
+ #: new-user-approve.php:372
124
+ #, php-format
125
+ msgid "You have been approved to access %s"
126
+ msgstr ""
127
+
128
+ #: new-user-approve.php:373
129
+ #, php-format
130
+ msgid "Username: %s"
131
+ msgstr ""
132
+
133
+ #: new-user-approve.php:374
134
+ #, php-format
135
+ msgid "Password: %s"
136
+ msgstr ""
137
+
138
+ #: new-user-approve.php:378
139
+ #, php-format
140
+ msgid "[%s] Registration Approved"
141
+ msgstr ""
142
+
143
+ #: new-user-approve.php:397
144
+ #, php-format
145
+ msgid "You have been denied access to %s"
146
+ msgstr ""
147
+
148
+ #: new-user-approve.php:400
149
+ #, php-format
150
+ msgid "[%s] Registration Denied"
151
+ msgstr ""
152
+
153
+ #: new-user-approve.php:413
154
+ msgid ""
155
+ "An email has been sent to the site administrator. The administrator will "
156
+ "review the information that has been submitted and either approve or deny "
157
+ "your request."
158
+ msgstr ""
159
+
160
+ #: new-user-approve.php:414
161
+ msgid ""
162
+ "You will receive an email with instructions on what you will need to do "
163
+ "next. Thanks for your patience."
164
+ msgstr ""
165
+
166
+ #: new-user-approve.php:418
167
+ msgid "Pending Approval"
168
+ msgstr ""
169
+
170
+ #: new-user-approve.php:418
171
+ msgid "Registration successful."
172
+ msgstr ""
173
+
174
+ #: new-user-approve.php:466
175
+ #, php-format
176
+ msgid ""
177
+ "Welcome to %s. This site is accessible to approved users only. To be "
178
+ "approved, you must first register."
179
+ msgstr ""
180
+
181
+ #: new-user-approve.php:471
182
+ msgid ""
183
+ "After you register, your request will be sent to the site administrator for "
184
+ "approval. You will then receive an email with further instructions."
185
+ msgstr ""
186
+
187
+ #. Plugin Name of an extension
188
+ msgid "New User Approve"
189
+ msgstr ""
190
+
191
+ #. Plugin URI of an extension
192
+ msgid "http://www.picklewagon.com/wordpress/new-user-approve"
193
+ msgstr ""
194
+
195
+ #. Description of an extension
196
+ msgid ""
197
+ "This plugin allows administrators to approve users once they register. Only "
198
+ "approved users will be allowed to access the blog."
199
+ msgstr ""
200
+
201
+ #. Author of an extension
202
+ msgid "Josh Harrison"
203
+ msgstr ""
204
+
205
+ #. Author URI of an extension
206
+ msgid "http://www.picklewagon.com/"
207
+ msgstr ""
new-user-approve.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin URI: http://www.picklewagon.com/wordpress/new-user-approve
5
  Description: This plugin allows administrators to approve users once they register. Only approved users will be allowed to access the blog.
6
  Author: Josh Harrison
7
- Version: 1.1.3
8
  Author URI: http://www.picklewagon.com/
9
  */
10
 
@@ -24,19 +24,6 @@
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
27
- /**
28
- * Guess the wp-content and plugin urls/paths
29
- */
30
- if ( !defined('WP_CONTENT_URL') )
31
- define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
32
- if ( !defined('WP_CONTENT_DIR') )
33
- define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
34
-
35
- if (!defined('PLUGIN_URL'))
36
- define('PLUGIN_URL', WP_CONTENT_URL . '/plugins/');
37
- if (!defined('PLUGIN_PATH'))
38
- define('PLUGIN_PATH', WP_CONTENT_DIR . '/plugins/');
39
-
40
  if (!class_exists('pw_new_user_approve')) {
41
  class pw_new_user_approve {
42
  /**
@@ -75,15 +62,14 @@ if (!class_exists('pw_new_user_approve')) {
75
  /**
76
  * PHP 5 Constructor
77
  */
78
- function __construct(){
79
- // Language Setup
80
- $locale = get_locale();
81
- $mo = dirname(__FILE__) . "/languages/" . $this->localizationName . "-".$locale.".mo";
82
- load_textdomain($this->localizationDomain, $mo);
83
 
84
  // Constants setup
85
- $this->pluginurl = PLUGIN_URL . dirname(plugin_basename(__FILE__)).'/';
86
- $this->pluginpath = PLUGIN_PATH . dirname(plugin_basename(__FILE__)).'/';
87
 
88
  // Initialize the options
89
  $this->get_options();
@@ -92,7 +78,6 @@ if (!class_exists('pw_new_user_approve')) {
92
  add_action('admin_menu', array(&$this, 'admin_menu_link'));
93
  add_action('admin_footer', array(&$this, 'admin_scripts_footer'));
94
  add_action('init', array(&$this, 'init'));
95
- add_action('admin_head', array(&$this, 'add_admin_css'));
96
  add_action('register_post', array(&$this, 'send_approval_email'), 10, 3);
97
  add_action('init', array(&$this, 'process_input'));
98
  add_action('lostpassword_post', array(&$this, 'lost_password'));
@@ -107,7 +92,9 @@ if (!class_exists('pw_new_user_approve')) {
107
  function get_options() {
108
  // Don't forget to set up the default options
109
  if (!$theOptions = get_option($this->optionsName)) {
110
- $theOptions = array('default'=>'options');
 
 
111
  update_option($this->optionsName, $theOptions);
112
  }
113
  $this->options = $theOptions;
@@ -124,8 +111,8 @@ if (!class_exists('pw_new_user_approve')) {
124
  * @desc Adds the options subpanel
125
  */
126
  function admin_menu_link() {
127
- add_submenu_page('users.php', 'Approve New Users', 'Approve New Users', 'edit_users', basename(__FILE__), array(&$this, 'approve_admin'));
128
- add_filter( 'plugin_action_links', array(&$this, 'filter_plugin_actions'), 10, 2 );
129
  }
130
 
131
  /**
@@ -133,12 +120,12 @@ if (!class_exists('pw_new_user_approve')) {
133
  */
134
  function filter_plugin_actions($links, $file) {
135
  static $this_plugin;
136
- if( ! $this_plugin ) {
137
  $this_plugin = plugin_basename(__FILE__);
138
  }
139
 
140
- if( $file == $this_plugin ){
141
- $settings_link = '<a href="users.php?page=' . basename(__FILE__) . '">' . __('Settings') . '</a>';
142
  array_unshift( $links, $settings_link ); // before other links
143
  }
144
  return $links;
@@ -147,7 +134,7 @@ if (!class_exists('pw_new_user_approve')) {
147
  function admin_scripts_footer() {
148
  global $wp_db_version;
149
 
150
- if($_GET['page'] == basename(__FILE__)) {
151
  $page_id = ($wp_db_version >= 10851) ? '#pw_approve_tabs' : '#pw_approve_tabs > ul';
152
  ?>
153
  <script type="text/javascript">
@@ -181,7 +168,7 @@ if (!class_exists('pw_new_user_approve')) {
181
  }
182
  ?>
183
  <div>
184
- <p><span style="font-weight:bold;"><a href="users.php?page=<?php print basename(__FILE__) ?>">Users</a></span>:
185
  <?php foreach($user_status as $status =>$count) print "$count $status&nbsp;&nbsp;"; ?>
186
  </p>
187
  </div>
@@ -217,18 +204,18 @@ if (!class_exists('pw_new_user_approve')) {
217
  }
218
 
219
  if (isset($_GET['user']) && isset($_GET['status'])) {
220
- echo '<div id="message" class="updated fade"><p>User successfully updated.</p></div>';
221
  }
222
  ?>
223
  <div class="wrap">
224
- <h2>User Registration Approval</h2>
225
 
226
- <h3>User Management</h3>
227
  <div id="pw_approve_tabs">
228
  <ul>
229
- <li><a href="#pw_pending_users"><span>Users Pending Approval</span></a></li>
230
- <li><a href="#pw_approved_users"><span>Approved Users</span></a></li>
231
- <li><a href="#pw_denied_users"><span>Denied Users</span></a></li>
232
  </ul>
233
  <div id="pw_pending_users">
234
  <?php $this->approve_table($user_status, 'pending', true, true); ?>
@@ -253,14 +240,14 @@ if (!class_exists('pw_new_user_approve')) {
253
  <table class="widefat">
254
  <thead>
255
  <tr class="thead">
256
- <th><?php _e('ID') ?></th>
257
- <th><?php _e('Username') ?></th>
258
- <th><?php _e('Name') ?></th>
259
- <th><?php _e('E-mail') ?></th>
260
  <?php if ($approve && $deny) { ?>
261
- <th colspan="2" style="text-align: center"><?php _e('Actions') ?></th>
262
  <?php } else { ?>
263
- <th style="text-align: center"><?php _e('Actions') ?></th>
264
  <?php } ?>
265
  </tr>
266
  </thead>
@@ -285,7 +272,7 @@ if (!class_exists('pw_new_user_approve')) {
285
  } else {
286
  $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user->ID" ) );
287
  }
288
- $edit = "<strong><a href=\"$edit_link\">$user->user_login</a></strong><br />";
289
  } else {
290
  $edit = '<strong>' . $user->user_login . '</strong>';
291
  }
@@ -294,12 +281,12 @@ if (!class_exists('pw_new_user_approve')) {
294
  <td><?php echo $user->ID; ?></td>
295
  <td><?php echo $avatar." ".$edit; ?></td>
296
  <td><?php echo $user->first_name." ".$user->last_name; ?></td>
297
- <td><a href="mailto:<?php echo $user->user_email; ?>" title="email: <?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></a></td>
298
  <?php if ($approve) { ?>
299
- <td align="center"><a href="<?php echo $approve_link; ?>" title="Approve <?php echo $user->user_login; ?>"><?php _e('Approve') ?></a></td>
300
  <?php } ?>
301
  <?php if ($deny) { ?>
302
- <td align="center"><a href="<?php echo $deny_link; ?>" title="Deny <?php echo $user->user_login; ?>"><?php _e('Deny') ?></a></td>
303
  <?php } ?>
304
  </tr><?php
305
  $row++;
@@ -309,7 +296,16 @@ if (!class_exists('pw_new_user_approve')) {
309
  </table>
310
  <?php
311
  } else {
312
- echo "<p>There are no users with a status of $status</p>";
 
 
 
 
 
 
 
 
 
313
  }
314
  }
315
 
@@ -321,16 +317,16 @@ if (!class_exists('pw_new_user_approve')) {
321
  /* check if already exists */
322
  $user_data = get_userdatabylogin($user_login);
323
  if (!empty($user_data)){
324
- $errors->add('registration_required' , __("User name already exists"), 'message');
325
  } else {
326
  /* send email to admin for approval */
327
- $message = __($user_login.' ('.$user_email.') has requested a username at '.get_option('blogname')) . "\r\n\r\n";
328
  $message .= get_option('siteurl') . "\r\n\r\n";
329
- $message .= __('To approve or deny this user access to '.get_option('blogname'). ' go to') . "\r\n\r\n";
330
  $message .= get_option('siteurl') . "/wp-admin/users.php?page=".basename(__FILE__)."\r\n";
331
 
332
  // send the mail
333
- @wp_mail(get_option('admin_email'), sprintf(__('[%s] User Approval'), get_option('blogname')), $message);
334
 
335
  // create the user
336
  $user_pass = wp_generate_password();
@@ -350,9 +346,17 @@ if (!class_exists('pw_new_user_approve')) {
350
  $query = $wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d", $_GET['user']);
351
  $user = $wpdb->get_row($query);
352
 
353
- // reset password
354
- $new_pass = substr(md5(uniqid(microtime())), 0, 7);
355
- $wpdb->query("UPDATE $wpdb->users SET user_pass = MD5('$new_pass'), user_activation_key = '' WHERE ID = '$user->ID'");
 
 
 
 
 
 
 
 
356
  wp_cache_delete($user->ID, 'users');
357
  wp_cache_delete($user->user_login, 'userlogins');
358
 
@@ -361,13 +365,13 @@ if (!class_exists('pw_new_user_approve')) {
361
  $user_email = stripslashes($user->user_email);
362
 
363
  // format the message
364
- $message = sprintf(__('You have been approved to access %s '."\r\n"), get_option('blogname'));
365
- $message .= sprintf(__('Username: %s'), $user_login) . "\r\n";
366
- $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
367
  $message .= get_option('siteurl') . "/wp-login.php\r\n";
368
 
369
  // send the mail
370
- @wp_mail($user_email, sprintf(__('[%s] Registration Approved'), get_option('blogname')), $message);
371
 
372
  // change usermeta tag in database to approved
373
  update_usermeta($user->ID, 'pw_user_status', 'approved');
@@ -386,10 +390,10 @@ if (!class_exists('pw_new_user_approve')) {
386
  $user_email = stripslashes($user->user_email);
387
 
388
  // format the message
389
- $message = sprintf(__('You have been denied access to %s'), get_option('blogname'));
390
 
391
  // send the mail
392
- @wp_mail($user_email, sprintf(__('[%s] Registration Denied'), get_option('blogname')), $message);
393
 
394
  // change usermeta tag in database to denied
395
  update_usermeta($user->ID, 'pw_user_status', 'denied');
@@ -402,12 +406,12 @@ if (!class_exists('pw_new_user_approve')) {
402
  if ( $errors->get_error_code() )
403
  return $errors;
404
 
405
- $message = "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.";
406
- $message .= "You will receive an email with instructions on what you will need to do next. Thanks for your patience.";
407
 
408
- $errors->add('registration_required', __($message), 'message');
409
 
410
- login_header(__('Pending Approval'), '<p class="message register">' . __("Registration successful.") . '</p>', $errors);
411
 
412
  echo "<body></html>";
413
  exit();
@@ -455,25 +459,22 @@ if (!class_exists('pw_new_user_approve')) {
455
 
456
  function welcome_user($message) {
457
  if (!isset($_GET['action'])) {
458
- $message .= '<p class="message">Welcome to '.get_option('blogname').'. This site is accessible to approved users only. To be approved, you must first register.</p>';
 
459
  }
460
 
461
  if ($_GET['action'] == 'register' && !$_POST) {
462
- $message .= '<p class="message">After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions.</p>';
 
463
  }
464
 
465
  return $message;
466
  }
467
 
468
  function init() {
469
- if($_GET['page'] == basename(__FILE__)) {
470
  wp_enqueue_script('jquery-ui-tabs');
471
- }
472
- }
473
-
474
- function add_admin_css() {
475
- if($_GET['page'] == basename(__FILE__)) {
476
- echo '<link rel="stylesheet" href="'.$this->pluginurl.'ui.tabs.css'.'" type="text/css" />';
477
  }
478
  }
479
  } // End Class
4
  Plugin URI: http://www.picklewagon.com/wordpress/new-user-approve
5
  Description: This plugin allows administrators to approve users once they register. Only approved users will be allowed to access the blog.
6
  Author: Josh Harrison
7
+ Version: 1.2
8
  Author URI: http://www.picklewagon.com/
9
  */
10
 
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  if (!class_exists('pw_new_user_approve')) {
28
  class pw_new_user_approve {
29
  /**
62
  /**
63
  * PHP 5 Constructor
64
  */
65
+ function __construct() {
66
+ // Load up the localization file if we're using WordPress in a different language
67
+ // Just drop it in this plugin's "localization" folder and name it "pw_new_user_approve-[value in wp-config].mo"
68
+ load_plugin_textdomain($this->localizationDomain, dirname(__FILE__) . '/localization');
 
69
 
70
  // Constants setup
71
+ $this->pluginurl = WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)).'/';
72
+ $this->pluginpath = WP_PLUGIN_DIR . '/' . dirname(plugin_basename(__FILE__)).'/';
73
 
74
  // Initialize the options
75
  $this->get_options();
78
  add_action('admin_menu', array(&$this, 'admin_menu_link'));
79
  add_action('admin_footer', array(&$this, 'admin_scripts_footer'));
80
  add_action('init', array(&$this, 'init'));
 
81
  add_action('register_post', array(&$this, 'send_approval_email'), 10, 3);
82
  add_action('init', array(&$this, 'process_input'));
83
  add_action('lostpassword_post', array(&$this, 'lost_password'));
92
  function get_options() {
93
  // Don't forget to set up the default options
94
  if (!$theOptions = get_option($this->optionsName)) {
95
+ $theOptions = array(
96
+ 'default' => 'options'
97
+ );
98
  update_option($this->optionsName, $theOptions);
99
  }
100
  $this->options = $theOptions;
111
  * @desc Adds the options subpanel
112
  */
113
  function admin_menu_link() {
114
+ add_submenu_page('users.php', __('Approve New Users', $this->localizationDomain), __('Approve New Users', $this->localizationDomain), 'edit_users', basename(__FILE__), array(&$this, 'approve_admin'));
115
+ add_filter('plugin_action_links', array(&$this, 'filter_plugin_actions'), 10, 2);
116
  }
117
 
118
  /**
120
  */
121
  function filter_plugin_actions($links, $file) {
122
  static $this_plugin;
123
+ if (!$this_plugin) {
124
  $this_plugin = plugin_basename(__FILE__);
125
  }
126
 
127
+ if ($file == $this_plugin){
128
+ $settings_link = '<a href="users.php?page=' . basename(__FILE__) . '">' . __('Settings', $this->localizationDomain) . '</a>';
129
  array_unshift( $links, $settings_link ); // before other links
130
  }
131
  return $links;
134
  function admin_scripts_footer() {
135
  global $wp_db_version;
136
 
137
+ if (WP_ADMIN && $_GET['page'] == basename(__FILE__)) {
138
  $page_id = ($wp_db_version >= 10851) ? '#pw_approve_tabs' : '#pw_approve_tabs > ul';
139
  ?>
140
  <script type="text/javascript">
168
  }
169
  ?>
170
  <div>
171
+ <p><span style="font-weight:bold;"><a href="users.php?page=<?php print basename(__FILE__) ?>"><?php _e('Users', $this->localizationDomain) ?></a></span>:
172
  <?php foreach($user_status as $status =>$count) print "$count $status&nbsp;&nbsp;"; ?>
173
  </p>
174
  </div>
204
  }
205
 
206
  if (isset($_GET['user']) && isset($_GET['status'])) {
207
+ echo '<div id="message" class="updated fade"><p>'.__('User successfully updated.', $this->localizationDomain).'</p></div>';
208
  }
209
  ?>
210
  <div class="wrap">
211
+ <h2><?php _e('User Registration Approval', $this->localizationDomain) ?></h2>
212
 
213
+ <h3><?php _e('User Management', $this->localizationDomain) ?></h3>
214
  <div id="pw_approve_tabs">
215
  <ul>
216
+ <li><a href="#pw_pending_users"><span><?php _e('Users Pending Approval', $this->localizationDomain) ?></span></a></li>
217
+ <li><a href="#pw_approved_users"><span><?php _e('Approved Users', $this->localizationDomain) ?></span></a></li>
218
+ <li><a href="#pw_denied_users"><span><?php _e('Denied Users', $this->localizationDomain) ?></span></a></li>
219
  </ul>
220
  <div id="pw_pending_users">
221
  <?php $this->approve_table($user_status, 'pending', true, true); ?>
240
  <table class="widefat">
241
  <thead>
242
  <tr class="thead">
243
+ <th><?php _e('ID', $this->localizationDomain) ?></th>
244
+ <th><?php _e('Username', $this->localizationDomain) ?></th>
245
+ <th><?php _e('Name', $this->localizationDomain) ?></th>
246
+ <th><?php _e('E-mail', $this->localizationDomain) ?></th>
247
  <?php if ($approve && $deny) { ?>
248
+ <th colspan="2" style="text-align: center"><?php _e('Actions', $this->localizationDomain) ?></th>
249
  <?php } else { ?>
250
+ <th style="text-align: center"><?php _e('Actions', $this->localizationDomain) ?></th>
251
  <?php } ?>
252
  </tr>
253
  </thead>
272
  } else {
273
  $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user->ID" ) );
274
  }
275
+ $edit = '<strong><a href="$edit_link">' . $user->user_login . '</a></strong><br />';
276
  } else {
277
  $edit = '<strong>' . $user->user_login . '</strong>';
278
  }
281
  <td><?php echo $user->ID; ?></td>
282
  <td><?php echo $avatar." ".$edit; ?></td>
283
  <td><?php echo $user->first_name." ".$user->last_name; ?></td>
284
+ <td><a href="mailto:<?php echo $user->user_email; ?>" title="<?php _e('email:', $this->localizationDomain) ?> <?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></a></td>
285
  <?php if ($approve) { ?>
286
+ <td align="center"><a href="<?php echo $approve_link; ?>" title="<?php _e('Approve', $this->localizationDomain) ?> <?php echo $user->user_login; ?>"><?php _e('Approve', $this->localizationDomain) ?></a></td>
287
  <?php } ?>
288
  <?php if ($deny) { ?>
289
+ <td align="center"><a href="<?php echo $deny_link; ?>" title="<?php _e('Deny', $this->localizationDomain) ?> <?php echo $user->user_login; ?>"><?php _e('Deny', $this->localizationDomain) ?></a></td>
290
  <?php } ?>
291
  </tr><?php
292
  $row++;
296
  </table>
297
  <?php
298
  } else {
299
+ $status_i18n = $status;
300
+ if ($status == 'approved') {
301
+ $status_i18n = __('approved', $this->localizationDomain);
302
+ } else if ($status == 'denied') {
303
+ $status_i18n = __('denied', $this->localizationDomain);
304
+ } else if ($status == 'pending') {
305
+ $status_i18n = __('pending', $this->localizationDomain);
306
+ }
307
+
308
+ echo '<p>'.sprintf(__('There are no users with a status of %s', $this->localizationDomain), $status_i18n).'</p>';
309
  }
310
  }
311
 
317
  /* check if already exists */
318
  $user_data = get_userdatabylogin($user_login);
319
  if (!empty($user_data)){
320
+ $errors->add('registration_required' , __('User name already exists', $this->localizationDomain), 'message');
321
  } else {
322
  /* send email to admin for approval */
323
+ $message = sprintf(__('%1$s (%2$s) has requested a username at %3$s', $this->localizationDomain), $user_login, $user_email, get_option('blogname')) . "\r\n\r\n";
324
  $message .= get_option('siteurl') . "\r\n\r\n";
325
+ $message .= sprintf(__('To approve or deny this user access to %s go to', $this->localizationDomain), get_option('blogname')) . "\r\n\r\n";
326
  $message .= get_option('siteurl') . "/wp-admin/users.php?page=".basename(__FILE__)."\r\n";
327
 
328
  // send the mail
329
+ @wp_mail(get_option('admin_email'), sprintf(__('[%s] User Approval', $this->localizationDomain), get_option('blogname')), $message);
330
 
331
  // create the user
332
  $user_pass = wp_generate_password();
346
  $query = $wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d", $_GET['user']);
347
  $user = $wpdb->get_row($query);
348
 
349
+ // reset password to know what to send the user
350
+ $new_pass = wp_generate_password();
351
+ $data = array(
352
+ 'user_pass' => md5($new_pass),
353
+ 'user_activation_key' => '',
354
+ );
355
+ $where = array(
356
+ 'ID' => $user->ID,
357
+ );
358
+ $wpdb->update($wpdb->users, $data, $where, array('%s', '%s'), array('%d'));
359
+
360
  wp_cache_delete($user->ID, 'users');
361
  wp_cache_delete($user->user_login, 'userlogins');
362
 
365
  $user_email = stripslashes($user->user_email);
366
 
367
  // format the message
368
+ $message = sprintf(__('You have been approved to access %s', $this->localizationDomain), get_option('blogname')) . "\r\n";
369
+ $message .= sprintf(__('Username: %s', $this->localizationDomain), $user_login) . "\r\n";
370
+ $message .= sprintf(__('Password: %s', $this->localizationDomain), $new_pass) . "\r\n";
371
  $message .= get_option('siteurl') . "/wp-login.php\r\n";
372
 
373
  // send the mail
374
+ @wp_mail($user_email, sprintf(__('[%s] Registration Approved', $this->localizationDomain), get_option('blogname')), $message);
375
 
376
  // change usermeta tag in database to approved
377
  update_usermeta($user->ID, 'pw_user_status', 'approved');
390
  $user_email = stripslashes($user->user_email);
391
 
392
  // format the message
393
+ $message = sprintf(__('You have been denied access to %s', $this->localizationDomain), get_option('blogname'));
394
 
395
  // send the mail
396
+ @wp_mail($user_email, sprintf(__('[%s] Registration Denied', $this->localizationDomain), get_option('blogname')), $message);
397
 
398
  // change usermeta tag in database to denied
399
  update_usermeta($user->ID, 'pw_user_status', 'denied');
406
  if ( $errors->get_error_code() )
407
  return $errors;
408
 
409
+ $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.', $this->localizationDomain));
410
+ $message .= sprintf(__('You will receive an email with instructions on what you will need to do next. Thanks for your patience.', $this->localizationDomain));
411
 
412
+ $errors->add('registration_required', $message, 'message');
413
 
414
+ login_header(__('Pending Approval', $this->localizationDomain), '<p class="message register">' . __("Registration successful.", $this->localizationDomain) . '</p>', $errors);
415
 
416
  echo "<body></html>";
417
  exit();
459
 
460
  function welcome_user($message) {
461
  if (!isset($_GET['action'])) {
462
+ $inside = sprintf(__('Welcome to %s. This site is accessible to approved users only. To be approved, you must first register.', $this->localizationDomain), get_option('blogname'));
463
+ $message .= '<p class="message">' . $inside . '</p>';
464
  }
465
 
466
  if ($_GET['action'] == 'register' && !$_POST) {
467
+ $inside = sprintf(__('After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions.', $this->localizationDomain));
468
+ $message .= '<p class="message">' . $inside . '</p>';
469
  }
470
 
471
  return $message;
472
  }
473
 
474
  function init() {
475
+ if (WP_ADMIN && $_GET['page'] == basename(__FILE__)) {
476
  wp_enqueue_script('jquery-ui-tabs');
477
+ wp_enqueue_style('pw-admin-ui-tabs', $this->pluginurl.'ui.tabs.css');
 
 
 
 
 
478
  }
479
  }
480
  } // End Class
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: picklewagon
3
  Donate link: http://www.picklewagon.com/wordpress/
4
  Tags: users, registration
5
- Requires at least: 2.5
6
- Tested up to: 2.8
7
- Stable tag: 1.1.3
8
 
9
  New User Approve is a Wordpress plugin that allows a blog administrator to
10
  approve a user before they are able to access and login to the blog.
@@ -26,13 +26,51 @@ user will not be able to login to the site.
26
  == Installation ==
27
 
28
  1. Upload new-user-approve to the wp-content/plugins directory
29
- 2. Activate the plugin through the Plugins menu in WordPress
30
  3. No configuration necessary.
31
 
32
  == Frequently Asked Questions ==
33
 
34
- No FAQ yet.
 
 
 
35
 
36
  == Screenshots ==
37
 
38
- No screenshots yet.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  Contributors: picklewagon
3
  Donate link: http://www.picklewagon.com/wordpress/
4
  Tags: users, registration
5
+ Requires at least: 2.6
6
+ Tested up to: 2.9
7
+ Stable tag: 1.2
8
 
9
  New User Approve is a Wordpress plugin that allows a blog administrator to
10
  approve a user before they are able to access and login to the blog.
26
  == Installation ==
27
 
28
  1. Upload new-user-approve to the wp-content/plugins directory
29
+ 2. Activate the plugin through the Plugins menu in WordPress
30
  3. No configuration necessary.
31
 
32
  == Frequently Asked Questions ==
33
 
34
+ = Why am I not getting the emails when a new user registers? =
35
+
36
+ The New User Approve plugin uses the functions provided by WordPress to send
37
+ email. Make sure your host is setup correctly to send email if this happens.
38
 
39
  == Screenshots ==
40
 
41
+ 1. The backend to manage approving and denying users.
42
+
43
+ == Changelog ==
44
+
45
+ = 1.2 =
46
+ * add localization support
47
+ * add a changelog to readme.txt
48
+ * remove plugin constants that have been defined since 2.6
49
+ * correct the use of db prepare statements/use prepare on all SQL statements
50
+ * add wp_enqueue_style for the admin style sheet
51
+
52
+ = 1.1.3 =
53
+ * replace calls to esc_url() with clean_url() to make plugin compatible with versions less than 2.8
54
+
55
+ = 1.1.2 =
56
+ * fix the admin ui tab interface for 2.8
57
+ * add a link to the users profile in the admin interface
58
+ * fix bug when using email address to retrieve lost password
59
+ * show blog title correctly on login screen
60
+ * use get_option() instead of get_settings()
61
+
62
+ = 1.1.1 =
63
+ * fix approve/deny links
64
+ * fix formatting issue with email to admin to approve user
65
+
66
+ = 1.1 =
67
+ * correctly display error message if registration is empty
68
+ * add a link to the options page from the plugin dashboard
69
+ * clean up code
70
+ * style updates
71
+ * if a user is created through the admin interface, set the status as approved instead of pending
72
+ * add avatars to user management admin page
73
+ * improvements to SQL used
74
+ * verify the user does not already exist before the process is started
75
+ * add nonces to approve and deny actions
76
+ * temporary fix for pagination bug
screenshot-1.png ADDED
Binary file