Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Worpdress基于自定义配置文件字段值编辑用户的权限_Php_Wordpress_Permissions_User Profile - Fatal编程技术网

Php Worpdress基于自定义配置文件字段值编辑用户的权限

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

我正在尝试授予“编辑”角色用户权限,以便仅编辑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_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){?>
国家