Php Worpdress基于自定义配置文件字段值编辑用户的权限
我正在尝试授予“编辑”角色用户权限,以便仅编辑wordpress中具有特定自定义字段的用户 在本例中,自定义字段是用户国籍,我已将其添加到user_meta,如下所示:Php Worpdress基于自定义配置文件字段值编辑用户的权限,php,wordpress,permissions,user-profile,Php,Wordpress,Permissions,User Profile,我正在尝试授予“编辑”角色用户权限,以便仅编辑wordpress中具有特定自定义字段的用户 在本例中,自定义字段是用户国籍,我已将其添加到user_meta,如下所示: add_action( 'show_user_profile', 'my_show_extra_profile_fields' ); add_action( 'edit_user_profile', 'my_show_extra_profile_fields' ); function my_show_extra_profile
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<table class="form-table">
<tr>
<th><label for="country">Country</label></th>
<td>
<input type="text" name="country" id="country" value="<?php echo esc_attr( get_the_author_meta( 'country', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">Please enter country.</span>
</td>
</tr>
<tr>
update_usermeta( $user_id, 'country', $_POST['country'] );
add_操作('show_user_profile'、'my_show_extra_profile_fields');
添加操作(“编辑用户配置文件”、“我的显示额外配置文件”字段);
函数my_show_extra_profile_字段($user){?>
国家