根据您的技能,您应该为此创建一个主题模板。到目前为止,您对希望用户编辑的内容拥有最大的控制权
您可以使用此模板进行基本操作。希望有帮助:
<?php
global $user_ID, $user_identity, $user_level;
if ($user_ID) {
if($_POST)
{
$message = "Your profile updated successfully.";
$first = $wpdb->escape($_POST[\'first_name\']);
$last = $wpdb->escape($_POST[\'last_name\']);
$email = $wpdb->escape($_POST[\'email\']);
$user_url = $wpdb->escape($_POST[\'website\']);
$description = $wpdb->escape($_POST[\'desc\']);
$password = $wpdb->escape($_POST[\'pwd\']);
$confirm_password = $wpdb->escape($_POST[\'confirm\']);
update_user_meta( $user_ID, \'first_name\', $first );
update_user_meta( $user_ID, \'last_name\', $last );
update_user_meta( $user_ID, \'description\', $description );
wp_update_user( array (\'ID\' => $user_ID, \'user_url\' => $user_url) );
if(isset($email)) {
if (preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/", $email)){
wp_update_user( array (\'ID\' => $user_ID, \'user_email\' => $email) ) ;
}
else { $message = "<div id=\'error\'>Please enter a valid email id.</div>"; }
}
if($password) {
if (strlen($password) < 5 || strlen($password) > 15) {
$message = "<div id=\'error\'>Password must be 5 to 15 characters in length.</div>";
}
//elseif( $password == $confirm_password ) {
elseif(isset($password) && $password != $confirm_password) {
$message = "<div class=\'error\'>Password Mismatch</div>";
} elseif ( isset($password) && !empty($password) ) {
$update = wp_set_password( $password, $user_ID );
$message = "<div id=\'success\'>Your profile updated successfully.</div>";
}
}
}
}
/*
Template Name: Your account
*/
if ($user_ID) {
$user_info = get_userdata($user_ID);
get_header();
?>
<div id="user-interact">
<div class="indent">
<div id="respond">
<h1 class="margin">Edit your account</h1>
<?php if($_POST) {
echo "<div id=\'result\'><div class=\'message\'>".$message."</div></div>";
}
?>
<form action="" method="post">
<label>First name:</label><br /><input type="text" name="first_name" class="text" value="<?php echo $user_info->first_name; ?>" maxlength="30" /> <br />
<label>Last name:</label><br /><input type="text" name="last_name" class="text" value="<?php echo $user_info->last_name; ?>" maxlength="30" /> <br />
<label>Email address:</label><br /><input type="text" name="email" class="text" value="<?php echo $user_info->user_email; ?>" maxlength="30" /><br />
<label>Website:</label><br /><input type="text" name="website" class="text" value="<?php echo $user_info->user_url; ?>" maxlength="30" /> <br />
<label>About yourself:</label><br /><textarea name="desc" class="text" rows="5"><?php echo $user_info->description; ?></textarea> <br />
<label>Change password</label><br /><input type="password" name="pwd" class="text" maxlength="15" /> <br />
<label>Retype password</label><br /><input type="password" name="confirm" class="text" maxlength="15" /><br />
<span class="grey">If you would like to change the password type a new one. Otherwise leave this blank</span>
<br /><br />
<input type="submit" name="submit" value="Submit" id="submit" />
</form>
</div>
</div>
</div>
<?php
get_footer();
}
else {
$redirect_to = get_bloginfo(\'url\')."/login";//change this to your custom login url
wp_safe_redirect($redirect_to);
exit;
}
?>
创建一个新的PHP页面并通过此脚本
更改此
/*
Template Name: Your account
*/
与您需要的内容共享,并将页面保存到服务器。现在,您可以在创建新页面时选择它。