您的位置:首页 > 其它

edit user profile - Action介绍

2015-05-17 15:58 253 查看
原文:Plugin API/Action Reference/edit user profile

Action介绍

这个Action钩子通常会在用户属性编辑页面需要输出新的字段或者在编辑页面底部添加更多内容的时候会使用到。

这个钩子只有在用户编辑其他用户的属性时候才会触发(不是当前登录用户)。如果需要所有用户编辑页面都会触发事件,那应该使用
show_user_profile
钩子。

参数

$user

(
object
) (
optional
) 当前被正在被编辑的用户。

默认:
None


例子

/**
* Show custom user profile fields
* @param  obj $user The user object.
* @return void
*/
function numediaweb_custom_user_profile_fields($user) {
?>
<table class="form-table">
<tr>
<th>
<label for="tc_location"><?php _e('Location'); ?></label>
</th>
<td>
<input type="text" name="tc_location" id="tc_location" value="<?php echo esc_attr( get_the_author_meta( 'tc_location', $user->ID ) ); ?>" class="regular-text" />
<br><span class="description"><?php _e('Your location.', 'travelcat'); ?></span>
</td>
</tr>
<tr>
<th>
<label for="tc_favorites"><?php _e('Favorites', 'travelcat'); ?></label>
</th>
<td>
<input type="text" name="tc_favorites" id="tc_favorites" value="<?php echo esc_attr( get_the_author_meta( 'tc_favorites', $user->ID ) ); ?>" class="regular-text" />
<br><span class="description"><?php _e('Can you share a few of your favorite places to be or to stay?', 'travelcat'); ?></span>
<br><span class="description"><?php _e('Separate by commas.', 'travelcat'); ?></span>
</td>
</tr>
<tr>
<th>
<label for="tc_travel_map"><?php _e('Travel map', 'travelcat'); ?></label>
</th>
<td>
<input type="text" name="tc_travel_map" id="tc_travel_map" value="<?php echo esc_attr( get_the_author_meta( 'tc_travel_map', $user->ID ) ); ?>" class="regular-text" />
<br><span class="description"><?php _e('Been there / Going there within a year / Wish list.', 'travelcat'); ?></span>
<br><span class="description"><?php _e('Separate by commas.', 'travelcat'); ?></span>
</td>
</tr>
</table>
<?php
}
add_action('show_user_profile', 'numediaweb_custom_user_profile_fields');
add_action('edit_user_profile', 'numediaweb_custom_user_profile_fields');


源文件

edit_user_profile
钩子的源文件在 /wp-admin/user-edit.php
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: