Roles update + UI from Owen.
git-svn-id: https://develop.svn.wordpress.org/trunk@2704 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
19ab84315c
commit
d77f5373ec
@ -301,26 +301,33 @@ function wp_delete_category($cat_ID) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function wp_delete_user($id) {
|
||||
function wp_delete_user($id, $reassign = 'novalue') {
|
||||
global $wpdb;
|
||||
|
||||
$id = (int) $id;
|
||||
|
||||
$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
|
||||
|
||||
if ($post_ids) {
|
||||
$post_ids = implode(',', $post_ids);
|
||||
|
||||
// Delete comments, *backs
|
||||
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
|
||||
// Clean cats
|
||||
$wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
|
||||
// Clean post_meta
|
||||
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
|
||||
|
||||
if($reassign == 'novalue') {
|
||||
$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
|
||||
|
||||
if ($post_ids) {
|
||||
$post_ids = implode(',', $post_ids);
|
||||
|
||||
// Delete comments, *backs
|
||||
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
|
||||
// Clean cats
|
||||
$wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
|
||||
// Clean post_meta
|
||||
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
|
||||
// Delete posts
|
||||
$wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
|
||||
}
|
||||
|
||||
// Clean links
|
||||
$wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
|
||||
// Delete posts
|
||||
$wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
|
||||
} else {
|
||||
$reassign = (int)$reassign;
|
||||
$wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}");
|
||||
$wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}");
|
||||
}
|
||||
|
||||
// FINALLY, delete user
|
||||
|
@ -11,7 +11,7 @@ include('admin-header.php');
|
||||
<h2><?php _e('General Options') ?></h2>
|
||||
<form name="form1" method="post" action="options.php">
|
||||
<input type="hidden" name="action" value="update" />
|
||||
<input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','siteurl','admin_email','users_can_register','gmt_offset','date_format','time_format','home','start_of_week','comment_registration'" />
|
||||
<input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','siteurl','admin_email','users_can_register','gmt_offset','date_format','time_format','home','start_of_week','comment_registration','default_role'" />
|
||||
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
||||
<tr valign="top">
|
||||
<th width="33%" scope="row"><?php _e('Weblog title:') ?></th>
|
||||
@ -48,6 +48,17 @@ include('admin-header.php');
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('New User Default Role:') ?></th>
|
||||
<td><label for="default_role">
|
||||
<select name="default_role" id="default_role"><?php
|
||||
foreach($wp_roles->role_names as $role => $name) {
|
||||
$selected = (get_settings('default_role') == $role) ? 'selected="selected"' : '';
|
||||
echo "<option {$selected} value=\"{$role}\">{$name}</option>";
|
||||
}
|
||||
?></select></label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Date and Time') ?></legend>
|
||||
|
@ -11,7 +11,7 @@ include('admin-header.php');
|
||||
<h2><?php _e('Writing Options') ?></h2>
|
||||
<form name="form1" method="post" action="options.php">
|
||||
<input type="hidden" name="action" value="update" />
|
||||
<input type="hidden" name="page_options" value="'default_post_edit_rows','use_smilies','use_balanceTags','ping_sites','mailserver_url', 'mailserver_port','mailserver_login','mailserver_pass','default_category','default_email_category','new_users_can_blog'" />
|
||||
<input type="hidden" name="page_options" value="'default_post_edit_rows','use_smilies','use_balanceTags','ping_sites','mailserver_url', 'mailserver_port','mailserver_login','mailserver_pass','default_category','default_email_category'," />
|
||||
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
||||
<tr valign="top">
|
||||
<th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th>
|
||||
@ -39,12 +39,6 @@ endforeach;
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Newly registered members:') ?></th>
|
||||
<td> <label for="new_users_can_blog0"><input name="new_users_can_blog" id="new_users_can_blog0" type="radio" value="0" <?php checked('0', get_settings('new_users_can_blog')); ?> /> <?php _e('Cannot write articles') ?></label><br />
|
||||
<label for="new_users_can_blog1"><input name="new_users_can_blog" id="new_users_can_blog1" type="radio" value="1" <?php checked('1', get_settings('new_users_can_blog')); ?> /> <?php _e('May submit drafts for review') ?></label><br />
|
||||
<label for="new_users_can_blog2"><input name="new_users_can_blog" id="new_users_can_blog2" type="radio" value="2" <?php checked('2', get_settings('new_users_can_blog')); ?> /> <?php _e('May publish articles') ?></label><br /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<fieldset class="options">
|
||||
@ -98,4 +92,4 @@ endforeach;
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php include('./admin-footer.php') ?>
|
||||
<?php include('./admin-footer.php') ?>
|
||||
|
@ -24,6 +24,38 @@ require_once('../wp-config.php');
|
||||
auth_redirect();
|
||||
switch($action) {
|
||||
|
||||
case 'IErightclick':
|
||||
|
||||
$bookmarklet_height= 550;
|
||||
|
||||
?>
|
||||
|
||||
<div class="menutop"> IE one-click bookmarklet</div>
|
||||
|
||||
<table width="100%" cellpadding="20">
|
||||
<tr><td>
|
||||
|
||||
<p>To have a one-click bookmarklet, just copy and paste this<br />into a new text file:</p>
|
||||
<?php
|
||||
$regedit = "REGEDIT4\r\n[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Post To &WP : ". get_settings('blogname') ."]\r\n@=\"javascript:doc=external.menuArguments.document;Q=doc.selection.createRange().text;void(btw=window.open('". get_settings('siteurl') ."/wp-admin/bookmarklet.php?text='+escape(Q)+'".$bookmarklet_tbpb."&popupurl='+escape(doc.location.href)+'&popuptitle='+escape(doc.title),'bookmarklet','scrollbars=no,width=480,height=".$bookmarklet_height.",left=100,top=150,status=yes'));btw.focus();\"\r\n\"contexts\"=hex:31\"";
|
||||
?>
|
||||
<pre style="margin: 20px; background-color: #cccccc; border: 1px dashed #333333; padding: 5px; font-size: 12px;"><?php echo $regedit; ?></pre>
|
||||
<p>Save it as wordpress.reg, and double-click on this file in an Explorer<br />
|
||||
window. Answer Yes to the question, and restart Internet Explorer.<br /><br />
|
||||
That's it, you can now right-click in an IE window and select <br />
|
||||
'Post to WP' to make the bookmarklet appear. :)</p>
|
||||
|
||||
<p align="center">
|
||||
<form>
|
||||
<input class="search" type="button" value="1" name="Close this window" />
|
||||
</form>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
|
||||
get_currentuserinfo();
|
||||
@ -100,43 +132,12 @@ case 'update':
|
||||
wp_redirect('profile.php?updated=true');
|
||||
break;
|
||||
|
||||
case 'IErightclick':
|
||||
|
||||
$bookmarklet_height= 550;
|
||||
|
||||
?>
|
||||
|
||||
<div class="menutop"> IE one-click bookmarklet</div>
|
||||
|
||||
<table width="100%" cellpadding="20">
|
||||
<tr><td>
|
||||
|
||||
<p>To have a one-click bookmarklet, just copy and paste this<br />into a new text file:</p>
|
||||
<?php
|
||||
$regedit = "REGEDIT4\r\n[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Post To &WP : ". get_settings('blogname') ."]\r\n@=\"javascript:doc=external.menuArguments.document;Q=doc.selection.createRange().text;void(btw=window.open('". get_settings('siteurl') ."/wp-admin/bookmarklet.php?text='+escape(Q)+'".$bookmarklet_tbpb."&popupurl='+escape(doc.location.href)+'&popuptitle='+escape(doc.title),'bookmarklet','scrollbars=no,width=480,height=".$bookmarklet_height.",left=100,top=150,status=yes'));btw.focus();\"\r\n\"contexts\"=hex:31\"";
|
||||
?>
|
||||
<pre style="margin: 20px; background-color: #cccccc; border: 1px dashed #333333; padding: 5px; font-size: 12px;"><?php echo $regedit; ?></pre>
|
||||
<p>Save it as wordpress.reg, and double-click on this file in an Explorer<br />
|
||||
window. Answer Yes to the question, and restart Internet Explorer.<br /><br />
|
||||
That's it, you can now right-click in an IE window and select <br />
|
||||
'Post to WP' to make the bookmarklet appear. :)</p>
|
||||
|
||||
<p align="center">
|
||||
<form>
|
||||
<input class="search" type="button" value="1" name="Close this window" />
|
||||
</form>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
$parent_file = 'profile.php';
|
||||
include_once('admin-header.php');
|
||||
$profiledata = get_userdata($user_ID);
|
||||
$profileuser = new WP_User($user_ID);
|
||||
$profiledata = &$profileuser->data;
|
||||
|
||||
$bookmarklet_height= 440;
|
||||
|
||||
@ -159,8 +160,15 @@ if (isset($updated)) { ?>
|
||||
<td width="67%"><?php echo $profiledata->user_login; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Level:') ?></th>
|
||||
<td><?php echo $profiledata->user_level; ?></td>
|
||||
<th scope="row"><?php _e('Role:') ?></th>
|
||||
<td><?php
|
||||
$output = '';
|
||||
foreach($profileuser->roles as $role => $value) {
|
||||
if($output != '') $output .= ', ';
|
||||
$output .= $wp_roles->role_names[$role];
|
||||
}
|
||||
echo $output;
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Posts:') ?></th>
|
||||
@ -169,6 +177,25 @@ if (isset($updated)) { ?>
|
||||
echo $posts;
|
||||
?></td>
|
||||
</tr>
|
||||
<?php
|
||||
if(count($profileuser->caps) > count($profileuser->roles)):
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Additional Capabilities:') ?></th>
|
||||
<td><?php
|
||||
$output = '';
|
||||
foreach($profileuser->caps as $cap => $value) {
|
||||
if(!$wp_roles->is_role($cap)) {
|
||||
if($output != '') $output .= ', ';
|
||||
$output .= $value ? $cap : "Denied: {$cap}";
|
||||
}
|
||||
}
|
||||
echo $output;
|
||||
?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('First name:') ?></th>
|
||||
<td><input type="text" name="newuser_firstname" id="newuser_firstname" value="<?php echo $profiledata->first_name ?>" /></td>
|
||||
@ -229,6 +256,8 @@ if (isset($updated)) { ?>
|
||||
<td><textarea name="user_description" rows="5" id="textarea2" style="width: 99%; "><?php echo $profiledata->user_description ?></textarea></td>
|
||||
</tr>
|
||||
<?php
|
||||
do_action('show_user_profile');
|
||||
|
||||
$show_password_fields = apply_filters('show_password_fields', true);
|
||||
if ( $show_password_fields ) :
|
||||
?>
|
||||
|
@ -758,21 +758,20 @@ function translate_level_to_role($level) {
|
||||
case 10:
|
||||
case 9:
|
||||
case 8:
|
||||
return 'publisher';
|
||||
return 'administrator';
|
||||
case 7:
|
||||
case 6:
|
||||
case 5:
|
||||
return 'managing_editor';
|
||||
return 'editor';
|
||||
case 4:
|
||||
case 3:
|
||||
return 'copy_editor';
|
||||
case 2:
|
||||
return 'staff_writer';
|
||||
return 'author';
|
||||
case 1:
|
||||
return 'freelancer';
|
||||
return 'contributor';
|
||||
case 0:
|
||||
return 'visitor';
|
||||
return 'subscriber';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -215,11 +215,13 @@ function populate_options() {
|
||||
add_option('html_type', 'text/html');
|
||||
// 1.5.1
|
||||
add_option('use_trackback', 0);
|
||||
// 1.6
|
||||
add_option('default_role', 'Inactive');
|
||||
|
||||
populate_roles();
|
||||
|
||||
// Delete unused options
|
||||
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url');
|
||||
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
|
||||
foreach ($unusedoptions as $option) :
|
||||
delete_option($option);
|
||||
endforeach;
|
||||
|
@ -22,16 +22,27 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'switchposts':
|
||||
|
||||
check_admin_referer();
|
||||
|
||||
/* TODO: Switch all posts from one user to another user */
|
||||
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
|
||||
get_currentuserinfo();
|
||||
$edituser = get_userdata($user_id);
|
||||
if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
|
||||
$errors = array();
|
||||
if(empty($wp_user)) {
|
||||
$wp_user = new WP_User($user_id);
|
||||
$edituser = &$wp_user->data;
|
||||
}
|
||||
|
||||
if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.');
|
||||
|
||||
/* checking the nickname has been typed */
|
||||
if (empty($_POST["new_nickname"])) {
|
||||
die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
|
||||
return false;
|
||||
$errors['nickname'] = __("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)");
|
||||
}
|
||||
|
||||
$new_user_login = wp_specialchars($_POST['new_user_login']);
|
||||
@ -41,60 +52,61 @@ do_action('check_passwords', array($new_user_login, &$pass1, &$pass2));
|
||||
|
||||
if ( '' == $pass1 ) {
|
||||
if ( '' != $pass2 )
|
||||
die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
|
||||
$errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
|
||||
$updatepassword = '';
|
||||
} else {
|
||||
if ( '' == $pass2)
|
||||
die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
|
||||
$errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
|
||||
if ( $pass1 != $pass2 )
|
||||
die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
|
||||
$errors['pass'] = __("<strong>ERROR</strong>: you typed two different passwords.");
|
||||
$new_pass = $pass1;
|
||||
$updatepassword = "user_pass=MD5('$new_pass'), ";
|
||||
}
|
||||
|
||||
$new_firstname = wp_specialchars($_POST['new_firstname']);
|
||||
$new_lastname = wp_specialchars($_POST['new_lastname']);
|
||||
$new_nickname = $_POST['new_nickname'];
|
||||
$new_nicename = sanitize_title($new_nickname, $user_id);
|
||||
$new_icq = wp_specialchars($_POST['new_icq']);
|
||||
$new_aim = wp_specialchars($_POST['new_aim']);
|
||||
$new_msn = wp_specialchars($_POST['new_msn']);
|
||||
$new_yim = wp_specialchars($_POST['new_yim']);
|
||||
$new_email = wp_specialchars($_POST['new_email']);
|
||||
$new_url = wp_specialchars($_POST['new_url']);
|
||||
$new_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $new_url) ? $new_url : 'http://' . $new_url;
|
||||
$display_name = wp_specialchars($_POST['display_name']);
|
||||
$new_description = $_POST['new_description'];
|
||||
$edituser->user_login = wp_specialchars($_POST['new_user_login']);
|
||||
$edituser->user_nicename = sanitize_title($new_nickname, $user_id);
|
||||
$edituser->user_email = wp_specialchars($_POST['new_email']);
|
||||
$edituser->user_url = wp_specialchars($_POST['new_url']);
|
||||
$edituser->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $edituser->user_url) ? $edituser->user_url : 'http://' . $edituser->user_url;
|
||||
$edituser->display_name = wp_specialchars($_POST['display_name']);
|
||||
|
||||
$result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$new_user_login', $updatepassword user_email='$new_email', user_url='$new_url', user_nicename = '$new_nicename', display_name = '$display_name' WHERE ID = '$user_id'");
|
||||
$edituser->first_name = wp_specialchars($_POST['new_firstname']);
|
||||
$edituser->last_name = wp_specialchars($_POST['new_lastname']);
|
||||
$edituser->nickname = $_POST['new_nickname'];
|
||||
$edituser->icq = wp_specialchars($_POST['new_icq']);
|
||||
$edituser->aim = wp_specialchars($_POST['new_aim']);
|
||||
$edituser->msn = wp_specialchars($_POST['new_msn']);
|
||||
$edituser->yim = wp_specialchars($_POST['new_yim']);
|
||||
$edituser->description = $_POST['new_description'];
|
||||
|
||||
update_usermeta( $user_id, 'first_name', $new_firstname );
|
||||
update_usermeta( $user_id, 'last_name', $new_lastname );
|
||||
update_usermeta( $user_id, 'nickname', $new_nickname );
|
||||
update_usermeta( $user_id, 'description', $new_description );
|
||||
update_usermeta( $user_id, 'icq', $new_icq );
|
||||
update_usermeta( $user_id, 'aim', $new_aim );
|
||||
update_usermeta( $user_id, 'msn', $new_msn );
|
||||
update_usermeta( $user_id, 'yim', $new_yim );
|
||||
|
||||
header("Location: user-edit.php?user_id=$user_id&updated=true");
|
||||
|
||||
break;
|
||||
|
||||
case 'switchposts':
|
||||
|
||||
check_admin_referer();
|
||||
|
||||
/* TODO: Switch all posts from one user to another user */
|
||||
|
||||
break;
|
||||
if(count($errors) == 0) {
|
||||
$result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$edituser->user_login', $updatepassword user_email='$edituser->user_email', user_url='$edituser->user_url', user_nicename = '$edituser->user_nicename', display_name = '$edituser->display_name' WHERE ID = '$user_id'");
|
||||
|
||||
update_usermeta( $user_id, 'first_name', $edituser->firstname );
|
||||
update_usermeta( $user_id, 'last_name', $edituser->lastname );
|
||||
update_usermeta( $user_id, 'nickname', $edituser->nickname );
|
||||
update_usermeta( $user_id, 'description', $edituser->description );
|
||||
update_usermeta( $user_id, 'icq', $edituser->icq );
|
||||
update_usermeta( $user_id, 'aim', $edituser->aim );
|
||||
update_usermeta( $user_id, 'msn', $edituser->msn );
|
||||
update_usermeta( $user_id, 'yim', $edituser->yim );
|
||||
|
||||
$wp_user->set_role($_POST['new_role']);
|
||||
|
||||
header("Location: user-edit.php?user_id=$user_id&updated=true");
|
||||
} else {
|
||||
$wp_user->roles = array($_POST['new_role'] => true);
|
||||
}
|
||||
|
||||
default:
|
||||
include ('admin-header.php');
|
||||
|
||||
$edituser = get_userdata($user_id);
|
||||
if(empty($wp_user)) {
|
||||
$wp_user = new WP_User($user_id);
|
||||
$edituser = &$wp_user->data;
|
||||
}
|
||||
|
||||
if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
|
||||
if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.');
|
||||
?>
|
||||
|
||||
<?php if ( isset($_GET['updated']) ) : ?>
|
||||
@ -102,6 +114,15 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
|
||||
<p><strong><?php _e('User updated.') ?></strong></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ( isset($errors) ) : ?>
|
||||
<div class="error">
|
||||
<ul>
|
||||
<?php
|
||||
foreach($errors as $error) echo "<li>$error</li>";
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Edit User'); ?></h2>
|
||||
@ -112,14 +133,19 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
|
||||
<td width="73%"><input type="text" name="new_user_login" id="new_user_login" value="<?php echo $edituser->user_login; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Level:') ?></th>
|
||||
<td><?php echo $edituser->user_level; ?></td>
|
||||
<th scope="row"><?php _e('Role:') ?></th>
|
||||
<td><select name="new_role" id="new_role"><?php
|
||||
foreach($wp_roles->role_names as $role => $name) {
|
||||
$selected = (empty($wp_user->roles[$role])) ? '' : 'selected="selected"';
|
||||
echo "<option {$selected} value=\"{$role}\">{$name}</option>";
|
||||
}
|
||||
?></select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Posts:') ?></th>
|
||||
<td><?php echo get_usernumposts($edituser->ID); ?></td>
|
||||
</tr>
|
||||
<?php if ( '0000-00-00 00:00:00' != $edituser->user_registered ) { ?>
|
||||
<?php if ( isset($edituser->user_registered) && ('0000-00-00 00:00:00' != $edituser->user_registered) ) { ?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Registered on:') ?></th>
|
||||
<td><?php echo substr($edituser->user_registered, 0, 11); ?></td>
|
||||
@ -135,7 +161,7 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Profile:') ?></th>
|
||||
<td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->user_description ?></textarea></td>
|
||||
<td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->description ?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Nickname:') ?></th>
|
||||
@ -189,6 +215,8 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
do_action('edit_user_profile');
|
||||
|
||||
$show_password_fields = apply_filters('show_password_fields', true);
|
||||
if ( $show_password_fields ) :
|
||||
?>
|
||||
|
@ -8,88 +8,52 @@ $parent_file = 'profile.php';
|
||||
$action = $_REQUEST['action'];
|
||||
|
||||
switch ($action) {
|
||||
case 'adduser':
|
||||
check_admin_referer();
|
||||
|
||||
$user_login = wp_specialchars(trim($_POST['user_login']));
|
||||
$pass1 = $_POST['pass1'];
|
||||
$pass2 = $_POST['pass2'];
|
||||
$user_email = wp_specialchars(trim($_POST['email']));
|
||||
$user_firstname = wp_specialchars(trim($_POST['firstname']));
|
||||
$user_lastname = wp_specialchars(trim($_POST['lastname']));
|
||||
$user_uri = wp_specialchars(trim($_POST['uri']));
|
||||
|
||||
/* checking that username has been typed */
|
||||
if ($user_login == '')
|
||||
die (__('<strong>ERROR</strong>: Please enter a username.'));
|
||||
|
||||
/* checking the password has been typed twice */
|
||||
do_action('check_passwords', array($user_login, &$pass1, &$pass2));
|
||||
if ($pass1 == '' || $pass2 == '')
|
||||
die (__('<strong>ERROR</strong>: Please enter your password twice.'));
|
||||
|
||||
/* checking the password has been typed twice the same */
|
||||
if ($pass1 != $pass2)
|
||||
die (__('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
|
||||
|
||||
$user_nickname = $user_login;
|
||||
|
||||
if ( username_exists( $user_login ) )
|
||||
die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
|
||||
|
||||
/* checking e-mail address */
|
||||
if (empty($user_email)) {
|
||||
die (__("<strong>ERROR</strong>: please type an e-mail address"));
|
||||
return false;
|
||||
} else if (!is_email($user_email)) {
|
||||
die (__("<strong>ERROR</strong>: the email address isn't correct"));
|
||||
return false;
|
||||
}
|
||||
|
||||
$user_ID = create_user( $user_login, $pass1, $user_email, 0 );
|
||||
|
||||
update_usermeta( $user_ID, 'first_name', $user_firstname);
|
||||
update_usermeta( $user_ID, 'last_name', $user_lastname);
|
||||
update_usermeta( $user_ID, 'first_name', $user_firstname);
|
||||
|
||||
$stars = '';
|
||||
for ($i = 0; $i < strlen($pass1); $i = $i + 1)
|
||||
$stars .= '*';
|
||||
|
||||
$user_login = stripslashes($user_login);
|
||||
$message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
|
||||
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
|
||||
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
|
||||
|
||||
@wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
|
||||
header('Location: users.php');
|
||||
break;
|
||||
|
||||
case 'promote':
|
||||
check_admin_referer();
|
||||
|
||||
if (empty($_GET['prom'])) {
|
||||
if (empty($_POST['users'])) {
|
||||
header('Location: users.php');
|
||||
}
|
||||
|
||||
$id = (int) $_GET['id'];
|
||||
$prom = $_GET['prom'];
|
||||
if ( !current_user_can('edit_users') )
|
||||
die(__('You can’t edit users.'));
|
||||
|
||||
$user_data = get_userdata($id);
|
||||
|
||||
$usertopromote_level = $user_data->user_level;
|
||||
|
||||
if ( $user_level <= $usertopromote_level )
|
||||
die(__('Can’t change the level of a user whose level is higher than yours.'));
|
||||
|
||||
if ('up' == $prom) {
|
||||
$new_level = $usertopromote_level + 1;
|
||||
} elseif ('down' == $prom) {
|
||||
$new_level = $usertopromote_level - 1;
|
||||
$userids = $_POST['users'];
|
||||
foreach($userids as $id) {
|
||||
$user = new WP_User($id);
|
||||
$user->set_role($_POST['new_role']);
|
||||
}
|
||||
update_usermeta( $id, $wpdb->prefix . 'user_level', $new_level);
|
||||
|
||||
header('Location: users.php?update=promote');
|
||||
|
||||
header('Location: users.php');
|
||||
break;
|
||||
|
||||
case 'dodelete':
|
||||
|
||||
check_admin_referer();
|
||||
|
||||
if (empty($_POST['users'])) {
|
||||
header('Location: users.php');
|
||||
}
|
||||
|
||||
if ( !current_user_can('edit_users') )
|
||||
die(__('You can’t delete users.'));
|
||||
|
||||
$userids = $_POST['users'];
|
||||
|
||||
foreach($userids as $id) {
|
||||
switch($_POST['delete_option']) {
|
||||
case 'delete':
|
||||
wp_delete_user($id);
|
||||
break;
|
||||
case 'reassign':
|
||||
wp_delete_user($id, $_POST['reassign_user']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: users.php?update=del');
|
||||
|
||||
break;
|
||||
|
||||
@ -97,51 +61,189 @@ case 'delete':
|
||||
|
||||
check_admin_referer();
|
||||
|
||||
$id = (int) $_GET['id'];
|
||||
|
||||
if (!$id) {
|
||||
if (empty($_POST['users'])) {
|
||||
header('Location: users.php');
|
||||
}
|
||||
|
||||
$user_data = get_userdata($id);
|
||||
$usertodelete_level = $user_data->user_level;
|
||||
if ( !current_user_can('edit_users') )
|
||||
$error['edit_users'] = __('You can’t delete users.');
|
||||
|
||||
if ($user_level <= $usertodelete_level)
|
||||
die(__('Can’t delete a user whose level is higher than yours.'));
|
||||
$userids = $_POST['users'];
|
||||
|
||||
wp_delete_user($id);
|
||||
|
||||
header('Location: users.php?deleted=true');
|
||||
include ('admin-header.php');
|
||||
?>
|
||||
<form action="" method="post" name="updateusers" id="updateusers">
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Delete Users'); ?></h2>
|
||||
<p><?php _e('You have specified these users for deletion:'); ?></p>
|
||||
<ul>
|
||||
<?php
|
||||
foreach($userids as $id) {
|
||||
$user = new WP_User($id);
|
||||
echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />";
|
||||
echo "{$id}: {$user->data->user_login}</li>\n";
|
||||
}
|
||||
$all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
|
||||
$user_dropdown = '<select name="reassign_user">';
|
||||
foreach($all_logins as $login) {
|
||||
if(!in_array($login->ID, $userids)) {
|
||||
$user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
|
||||
}
|
||||
}
|
||||
$user_dropdown .= '</select>';
|
||||
?>
|
||||
</ul>
|
||||
<p><?php _e('What should be done with posts and links owned by this user?'); ?></p>
|
||||
<ul style="list-style:none;">
|
||||
<li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
|
||||
<?php _e('Delete all posts and links.'); ?></label></li>
|
||||
<li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
|
||||
<?php echo sprintf(__('<label for="delete_option1">Attribute all posts and links to:</label> %s'), $user_dropdown); ?></li>
|
||||
</ul>
|
||||
<input type="hidden" name="action" value="dodelete" />
|
||||
<p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" /></p>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
break;
|
||||
|
||||
case 'adduser':
|
||||
check_admin_referer();
|
||||
|
||||
$new_user_login = wp_specialchars(trim($_POST['user_login']));
|
||||
$new_pass1 = $_POST['pass1'];
|
||||
$new_pass2 = $_POST['pass2'];
|
||||
$new_user_email = wp_specialchars(trim($_POST['email']));
|
||||
$new_user_firstname = wp_specialchars(trim($_POST['firstname']));
|
||||
$new_user_lastname = wp_specialchars(trim($_POST['lastname']));
|
||||
$new_user_uri = wp_specialchars(trim($_POST['uri']));
|
||||
|
||||
$errors = array();
|
||||
|
||||
/* checking that username has been typed */
|
||||
if ($new_user_login == '')
|
||||
$errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
|
||||
|
||||
/* checking the password has been typed twice */
|
||||
do_action('check_passwords', array($new_user_login, &$new_pass1, &$new_pass2));
|
||||
if ($new_pass1 == '' || $new_pass2 == '')
|
||||
$errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.');
|
||||
|
||||
/* checking the password has been typed twice the same */
|
||||
if ($new_pass1 != $new_pass2)
|
||||
$errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.');
|
||||
|
||||
$new_user_nickname = $new_user_login;
|
||||
|
||||
if ( username_exists( $new_user_login ) )
|
||||
$errors['pass'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
|
||||
|
||||
/* checking e-mail address */
|
||||
if (empty($new_user_email)) {
|
||||
$errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address");
|
||||
} else if (!is_email($new_user_email)) {
|
||||
$errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct");
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
$user_ID = create_user( $new_user_login, $new_pass1, $new_user_email, 0 );
|
||||
|
||||
update_usermeta( $user_ID, 'first_name', $new_user_firstname);
|
||||
update_usermeta( $user_ID, 'last_name', $new_user_lastname);
|
||||
update_usermeta( $user_ID, 'first_name', $new_user_firstname);
|
||||
|
||||
$user = new WP_User($user_ID);
|
||||
$user->set_role(get_settings('default_role'));
|
||||
|
||||
$stars = '';
|
||||
for ($i = 0; $i < strlen($pass1); $i = $i + 1)
|
||||
$stars .= '*';
|
||||
|
||||
$user_login = stripslashes($new_user_login);
|
||||
$message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
|
||||
$message .= sprintf(__('Username: %s'), $new_user_login) . "\r\n\r\n";
|
||||
$message .= sprintf(__('E-mail: %s'), $new_user_email) . "\r\n";
|
||||
|
||||
@wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
|
||||
header('Location: users.php?update=add');
|
||||
die();
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
include ('admin-header.php');
|
||||
|
||||
$userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;");
|
||||
|
||||
foreach($userids as $userid) {
|
||||
$tmp_user = new WP_User($userid);
|
||||
$roles = array_keys($tmp_user->roles);
|
||||
$role = $roles[0];
|
||||
$roleclasses[$role][$tmp_user->data->user_login] = $tmp_user;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php if (isset($_GET['deleted'])) : ?>
|
||||
<div class="updated"><p><?php _e('User deleted.') ?></p></div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if (isset($_GET['update'])) :
|
||||
switch($_GET['update']) {
|
||||
case 'del':
|
||||
?>
|
||||
<div class="updated"><p><?php _e('User deleted.'); ?></p></div>
|
||||
<?php
|
||||
break;
|
||||
case 'add':
|
||||
?>
|
||||
<div class="updated"><p><?php _e('New user created.'); ?></p></div>
|
||||
<?php
|
||||
break;
|
||||
case 'promote':
|
||||
?>
|
||||
<div class="updated"><p><?php _e('Changed roles.'); ?></p></div>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
endif;
|
||||
if ( isset($errors) ) : ?>
|
||||
<div class="error">
|
||||
<ul>
|
||||
<?php
|
||||
foreach($errors as $error) echo "<li>$error</li>";
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
<form action="" method="post" name="updateusers" id="updateusers">
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Authors') ?></h2>
|
||||
<h2><?php _e('User List by Role'); ?></h2>
|
||||
<table cellpadding="3" cellspacing="3" width="100%">
|
||||
<?php
|
||||
foreach($roleclasses as $role => $roleclass) {
|
||||
ksort($roleclass);
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<th colspan="8" align="left">
|
||||
<h3><?php echo $wp_roles->role_names[$role]; ?></h3>
|
||||
</th>
|
||||
|
||||
<tr>
|
||||
<th><?php _e('ID') ?></th>
|
||||
<th><?php _e('Nickname') ?></th>
|
||||
<th><?php _e('Username') ?></th>
|
||||
<th><?php _e('Name') ?></th>
|
||||
<th><?php _e('E-mail') ?></th>
|
||||
<th><?php _e('Website') ?></th>
|
||||
<th><?php _e('Level') ?></th>
|
||||
<th><?php _e('Posts') ?></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<?php
|
||||
$authors =
|
||||
$users = get_author_user_ids();
|
||||
$style = '';
|
||||
foreach ($users as $user) {
|
||||
$user_data = get_userdata($user);
|
||||
foreach ($roleclass as $user_object) {
|
||||
$user_data = &$user_object->data;
|
||||
$email = $user_data->user_email;
|
||||
$url = $user_data->user_url;
|
||||
$short_url = str_replace('http://', '', $url);
|
||||
@ -151,24 +253,18 @@ default:
|
||||
if (strlen($short_url) > 35)
|
||||
$short_url = substr($short_url, 0, 32).'...';
|
||||
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
|
||||
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user' and post_status = 'publish'");
|
||||
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user_data->ID' and post_status = 'publish'");
|
||||
if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_data->ID' title='" . __('View posts') . "'>$numposts</a>";
|
||||
echo "
|
||||
<tr $style>
|
||||
<td align='center'>$user_data->ID</td>
|
||||
<td><strong>$user_data->user_login</strong></td>
|
||||
<td>$user_data->first_name $user_data->last_name</td>
|
||||
<td><input type='checkbox' name='users[]' id='user_{$user_data->ID}' value='{$user_data->ID}' /> <label for='user_{$user_data->ID}'>{$user_data->ID}</label></td>
|
||||
<td><label for='user_{$user_data->ID}'><strong>$user_data->user_login</strong></label></td>
|
||||
<td><label for='user_{$user_data->ID}'>$user_data->first_name $user_data->last_name</label></td>
|
||||
<td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
|
||||
<td><a href='$url' title='website: $url'>$short_url</a></td>
|
||||
<td align='center'>";
|
||||
if (($user_level >= 2) and ($user_level > $user_data->user_level) and ($user_data->user_level > 0))
|
||||
echo " <a href=\"users.php?action=promote&id=".$user_data->ID."&prom=down\">-</a> ";
|
||||
echo $user_data->user_level;
|
||||
if (($user_level >= 2) and ($user_level > ($user_data->user_level + 1)))
|
||||
echo " <a href=\"users.php?action=promote&id=".$user_data->ID."&prom=up\">+</a> ";
|
||||
echo "</td><td align='right'>$numposts</td>";
|
||||
<td><a href='$url' title='website: $url'>$short_url</a></td>";
|
||||
echo "<td align='right'>$numposts</td>";
|
||||
echo '<td>';
|
||||
if (($user_level >= 2) and ($user_level > $user_data->user_level))
|
||||
if (current_user_can('edit_users'))
|
||||
echo "<a href='user-edit.php?user_id=$user_data->ID' class='edit'>".__('Edit')."</a>";
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
@ -176,68 +272,29 @@ default:
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<h2><?php _e('Update Users'); ?></h2>
|
||||
<?php
|
||||
$users = get_nonauthor_user_ids();
|
||||
if ($users) {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Registered Users') ?></h2>
|
||||
<table cellpadding="3" cellspacing="3" width="100%">
|
||||
<tr>
|
||||
<th><?php _e('ID') ?></th>
|
||||
<th><?php _e('Nickname') ?></th>
|
||||
<th><?php _e('Name') ?></th>
|
||||
<th><?php _e('E-mail') ?></th>
|
||||
<th><?php _e('Website') ?></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php
|
||||
$style = '';
|
||||
foreach ($users as $user) {
|
||||
$user_data = get_userdata($user);
|
||||
$email = $user_data->user_email;
|
||||
$url = $user_data->user_url;
|
||||
$short_url = str_replace('http://', '', $url);
|
||||
$short_url = str_replace('www.', '', $short_url);
|
||||
if ('/' == substr($short_url, -1))
|
||||
$short_url = substr($short_url, 0, -1);
|
||||
if (strlen($short_url) > 35)
|
||||
$short_url = substr($short_url, 0, 32).'...';
|
||||
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
|
||||
echo "\n<tr $style>
|
||||
<td align='center'>$user_data->ID</td>
|
||||
<td><strong>$user_data->user_login</strong></td>
|
||||
<td>$user_data->first_name $user_data->last_name</td>
|
||||
<td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
|
||||
<td><a href='$url' title='website: $url'>$short_url</a></td>
|
||||
<td align='center'>";
|
||||
|
||||
if ($user_level >= 6)
|
||||
echo "<a href='users.php?action=promote&id=$user_data->ID&prom=up' class='edit'>". __('Promote') . '</a>';
|
||||
echo "</td>\n";
|
||||
echo '<td>';
|
||||
if (($user_level >= 6) and ($user_level > $user_data->user_level))
|
||||
echo "<a href='user-edit.php?user_id=$user_data->ID' class='edit'>".__('Edit')."</a>";
|
||||
echo '</td><td>';
|
||||
if ($user_level >= 6)
|
||||
echo "<a href='users.php?action=delete&id=$user_data->ID' class='delete' onclick='return confirm(\"" . __('You are about to delete this user \n OK to delete, Cancel to stop.') . "\")'>" . __('Delete'). '</a>';
|
||||
echo '</td></tr>';
|
||||
|
||||
$role_select = '<select name="new_role">';
|
||||
foreach($wp_roles->role_names as $role => $name) {
|
||||
$role_select .= "<option value=\"{$role}\">{$name}</option>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</table>
|
||||
<p><?php _e('Deleting a user also deletes all posts made by that user.') ?></p>
|
||||
$role_select .= '</select>';
|
||||
?>
|
||||
<ul style="list-style:none;">
|
||||
<li><input type="radio" name="action" id="action0" value="delete"> <label for="action0"><?php _e('Delete checked users.'); ?></label></li>
|
||||
<li><input type="radio" name="action" id="action1" value="promote"> <?php echo sprintf(__('<label for="action1">Set the Role of checked users to:</label> %s'), $role_select); ?></li>
|
||||
</ul>
|
||||
<p class="submit"><input type="submit" value="<?php _e('Update »'); ?>"></p>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
} ?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Add New User') ?></h2>
|
||||
<?php printf(__('<p>Users can <a href="%s/wp-register.php">register themselves</a> or you can manually create users here.</p>'), get_settings('siteurl')); ?>
|
||||
@ -246,23 +303,23 @@ echo "\n<tr $style>
|
||||
<tr>
|
||||
<th scope="row" width="33%"><?php _e('Nickname') ?>
|
||||
<input name="action" type="hidden" id="action" value="adduser" /></th>
|
||||
<td width="66%"><input name="user_login" type="text" id="user_login" /></td>
|
||||
<td width="66%"><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('First Name') ?> </th>
|
||||
<td><input name="firstname" type="text" id="firstname" /></td>
|
||||
<td><input name="firstname" type="text" id="firstname" value="<?php echo $new_user_firstname; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Last Name') ?> </th>
|
||||
<td><input name="lastname" type="text" id="lastname" /></td>
|
||||
<td><input name="lastname" type="text" id="lastname" value="<?php echo $new_user_lastname; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('E-mail') ?></th>
|
||||
<td><input name="email" type="text" id="email" /></td>
|
||||
<td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Website') ?></th>
|
||||
<td><input name="uri" type="text" id="uri" /></td>
|
||||
<td><input name="uri" type="text" id="uri" value="<?php echo $new_user_uri; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
$show_password_fields = apply_filters('show_password_fields', true);
|
||||
|
@ -246,6 +246,13 @@ textarea, input, select {
|
||||
padding: 0 1em 0 1em;
|
||||
}
|
||||
|
||||
.error {
|
||||
background: #FFEFF7;
|
||||
border: 1px solid #c69;
|
||||
margin: 1em 5% 10px;
|
||||
padding: 0 1em 0 1em;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
background: #fff;
|
||||
border: 1px solid #ccc;
|
||||
@ -679,4 +686,4 @@ a.dbx-toggle-hilite-closed, a.dbx-toggle-hilite-closed:visited {
|
||||
-moz-opacity: 0.8;
|
||||
-khtml-opacity: 0.8;
|
||||
filter: alpha(opacity=80);
|
||||
}
|
||||
}
|
||||
|
@ -1219,10 +1219,10 @@ function update_post_caches(&$posts) {
|
||||
function update_category_cache() {
|
||||
global $cache_categories, $wpdb;
|
||||
if($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")):
|
||||
foreach ($dogs as $catt)
|
||||
$cache_categories[$catt->cat_ID] = $catt;
|
||||
foreach ($dogs as $catt)
|
||||
$cache_categories[$catt->cat_ID] = $catt;
|
||||
return true;
|
||||
else:
|
||||
else :
|
||||
return false;
|
||||
endif;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ function get_userdata( $user_id ) {
|
||||
$user_id = (int) $user_id;
|
||||
if ( $user_id == 0 )
|
||||
return false;
|
||||
|
||||
|
||||
if ( isset( $cache_userdata[$user_id] ) )
|
||||
return $cache_userdata[$user_id];
|
||||
|
||||
@ -52,13 +52,42 @@ function get_userdata( $user_id ) {
|
||||
}
|
||||
|
||||
$cache_userdata[$user_id] = $user;
|
||||
|
||||
$cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$user_id];
|
||||
|
||||
return $cache_userdata[$user_id];
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('update_user_cache') ) :
|
||||
function update_user_cache() {
|
||||
global $cache_userdata, $wpdb;
|
||||
$level_key = $wpdb->prefix . 'user_level';
|
||||
$user_ids = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'");
|
||||
$user_ids = join(',', $user_ids);
|
||||
$query = apply_filters('user_cache_query', "SELECT * FROM $wpdb->users WHERE ID IN ($user_ids)");
|
||||
if ( $users = $wpdb->get_results( $query ) ) :
|
||||
foreach ($users as $user) :
|
||||
$metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'");
|
||||
foreach ( $metavalues as $meta ) {
|
||||
@ $value = unserialize($meta->meta_value);
|
||||
if ($value === FALSE)
|
||||
$value = $meta->meta_value;
|
||||
$user->{$meta->meta_key} = $value;
|
||||
// We need to set user_level from meta, not row
|
||||
if ( $wpdb->prefix . 'user_level' == $meta->meta_key )
|
||||
$user->user_level = $meta->meta_value;
|
||||
}
|
||||
|
||||
$cache_userdata[$user->ID] = $user;
|
||||
$cache_userdata[$user->user_login] =& $cache_userdata[$user->ID];
|
||||
endforeach;
|
||||
return true;
|
||||
else :
|
||||
return false;
|
||||
endif;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('get_userdatabylogin') ) :
|
||||
function get_userdatabylogin($user_login) {
|
||||
global $cache_userdata, $wpdb;
|
||||
@ -279,4 +308,4 @@ function wp_notify_moderator($comment_id) {
|
||||
}
|
||||
endif;
|
||||
|
||||
?>
|
||||
?>
|
||||
|
147
wp-register.php
147
wp-register.php
@ -14,47 +14,52 @@ case 'register':
|
||||
|
||||
$user_login = sanitize_user( $_POST['user_login'] );
|
||||
$user_email = $_POST['user_email'];
|
||||
|
||||
$errors = array();
|
||||
|
||||
if ( $user_login == '' )
|
||||
die (__('<strong>ERROR</strong>: Please enter a username.'));
|
||||
$errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
|
||||
|
||||
/* checking e-mail address */
|
||||
if ($user_email == '') {
|
||||
die (__('<strong>ERROR</strong>: Please type your e-mail address.'));
|
||||
$errors['user_email'] = __('<strong>ERROR</strong>: Please type your e-mail address.');
|
||||
} else if (!is_email($user_email)) {
|
||||
die (__('<strong>ERROR</strong>: The email address isn’t correct.'));
|
||||
$errors['user_email'] = __('<strong>ERROR</strong>: The email address isn’t correct.');
|
||||
}
|
||||
|
||||
if ( username_exists( $user_login ) )
|
||||
die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
|
||||
if ( username_exists( $user_login ) )
|
||||
$errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
|
||||
|
||||
$user_level = get_settings('new_users_can_blog');
|
||||
$password = substr( md5( uniqid( microtime() ) ), 0, 7);
|
||||
|
||||
$user_id = create_user( $user_login, $password, $user_email, $user_level );
|
||||
|
||||
do_action('user_register', $user_id);
|
||||
|
||||
$user_id = create_user( $user_login, $password, $user_email, 0 );
|
||||
if ( !$user_id ) {
|
||||
die (sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email')));
|
||||
$errors['user_id'] = sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email'));
|
||||
}
|
||||
|
||||
$stars = '';
|
||||
for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
|
||||
$stars .= '*';
|
||||
}
|
||||
if(count($errors) == 0) {
|
||||
$user = new WP_User($user_id);
|
||||
$user->set_role(get_settings('default_role'));
|
||||
|
||||
$message = sprintf(__('Username: %s'), $user_login) . "\r\n";
|
||||
$message .= sprintf(__('Password: %s'), $password) . "\r\n";
|
||||
$message .= get_settings('siteurl') . "/wp-login.php\r\n";
|
||||
do_action('user_register', $user_id);
|
||||
|
||||
wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
|
||||
|
||||
$message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
|
||||
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
|
||||
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
|
||||
|
||||
@wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
|
||||
|
||||
$stars = '';
|
||||
for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
|
||||
$stars .= '*';
|
||||
}
|
||||
|
||||
$message = sprintf(__('Username: %s'), $user_login) . "\r\n";
|
||||
$message .= sprintf(__('Password: %s'), $password) . "\r\n";
|
||||
$message .= get_settings('siteurl') . "/wp-login.php\r\n";
|
||||
|
||||
wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
|
||||
|
||||
$message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
|
||||
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
|
||||
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
|
||||
|
||||
@wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
@ -81,7 +86,57 @@ case 'register':
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>WordPress » <?php _e('Registration Form') ?></title>
|
||||
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
|
||||
<link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
|
||||
<style type="text/css">
|
||||
#user_email, #user_login, #submit {
|
||||
font-size: 1.7em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="login">
|
||||
<h1><a href="http://wordpress.org/">WordPress</a></h1>
|
||||
<h2><?php _e('Register for this blog') ?></h2>
|
||||
<?php if ( isset($errors) ) : ?>
|
||||
<div class="error">
|
||||
<ul>
|
||||
<?php
|
||||
foreach($errors as $error) echo "<li>$error</li>";
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form method="post" action="wp-register.php" id="registerform">
|
||||
<p><input type="hidden" name="action" value="register" />
|
||||
<label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" value="<?php echo $user_login; ?>" /><br /></p>
|
||||
<p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" value="<?php echo $user_email; ?>" /></p>
|
||||
<p>A password will be emailed to you.</p>
|
||||
<p class="submit"><input type="submit" value="<?php _e('Register') ?> »" id="submit" name="submit" /></p>
|
||||
</form>
|
||||
<ul>
|
||||
<li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">« <?php _e('Back to blog') ?></a></li>
|
||||
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
|
||||
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
|
||||
break;
|
||||
|
||||
case 'disabled':
|
||||
@ -110,45 +165,5 @@ case 'disabled':
|
||||
<?php
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>WordPress » <?php _e('Registration Form') ?></title>
|
||||
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
|
||||
<link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
|
||||
<style type="text/css">
|
||||
#user_email, #user_login, #submit {
|
||||
font-size: 1.7em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="login">
|
||||
<h1><a href="http://wordpress.org/">WordPress</a></h1>
|
||||
<h2><?php _e('Register for this blog') ?></h2>
|
||||
|
||||
<form method="post" action="wp-register.php" id="registerform">
|
||||
<p><input type="hidden" name="action" value="register" />
|
||||
<label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" /><br /></p>
|
||||
<p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" /></p>
|
||||
<p>A password will be emailed to you.</p>
|
||||
<p class="submit"><input type="submit" value="<?php _e('Register') ?> »" id="submit" name="submit" /></p>
|
||||
</form>
|
||||
<ul>
|
||||
<li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">« <?php _e('Back to blog') ?></a></li>
|
||||
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
|
||||
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
|
||||
break;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
@ -165,4 +165,4 @@ $wp_roles = new WP_Roles();
|
||||
|
||||
// Everything is loaded and initialized.
|
||||
do_action('init');
|
||||
?>
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user