Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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 wordpress中用户元的保留键-关于我_Php_Wordpress_Key_Meta - Fatal编程技术网

Php wordpress中用户元的保留键-关于我

Php wordpress中用户元的保留键-关于我,php,wordpress,key,meta,Php,Wordpress,Key,Meta,有人知道wordpress中保留了哪些元键(我不能用于自己的目的),如果有的话 还有,wordpress关于我的部分。有人知道怎么称呼它吗 提前感谢。发布元键: 您可能不想使用以下post元键: \u缩略图\u id-用于存储特色图像id \u edit\u last-心跳API使用 \u edit\u lock-心跳API使用 \u wp\u page\u template-存储页面模板 \u wp\u附加文件 \u wp\u附件\u元数据 \u菜单项{url,object,object\u

有人知道wordpress中保留了哪些元键(我不能用于自己的目的),如果有的话

还有,wordpress关于我的部分。有人知道怎么称呼它吗

提前感谢。

发布元键: 您可能不想使用以下post元键:

  • \u缩略图\u id
    -用于存储特色图像id
  • \u edit\u last
    -心跳API使用
  • \u edit\u lock
    -心跳API使用
  • \u wp\u page\u template
    -存储页面模板
  • \u wp\u附加文件
  • \u wp\u附件\u元数据
  • \u菜单项{url,object,object\u id,target,classes,xfn,…}
作为您的自定义元键,因为它们可能会被WordPress内核覆盖

用户元密钥: 类似地,对于这些用户元键:

  • 名字
  • 姓氏
  • 昵称
  • 说明
  • rich\u编辑
  • comment\u快捷方式
  • admin\u color
  • jabber
  • aim
  • yim
  • default\u password\u nag
  • 使用ssl
  • show\u admin\u bar\u front
  • 显示欢迎面板
  • 已删除\u wp\u指针
  • nav\u菜单\u最近编辑的
  • managenav菜单列设置
  • closedpostboxs{post,dashboard,page,…}
  • metaboxhidden{post,仪表板,页面,…}
  • meta-box-order{post,dashboard,page,…}
  • screen\u layout{post,dashboard,page,…}
以及以下具有默认表前缀的用户元键:

  • wp\u功能
  • wp\u用户级别
  • wp\u仪表板\u快速\u按\u最后一次\u发布\u id
  • wp\u用户设置
  • wp\u用户设置时间
因此,一般来说,我建议您为自己的元键添加前缀,以避免与WordPress核心或其他插件或主题冲突

如何显示用户元键? 如果要显示当前用户的所有用户元键,可以使用:

print_r( array_keys( get_user_meta( get_current_user_id() ) ) );
输出如下:

Array
(
    [0] => first_name
    [1] => last_name
    [2] => nickname
    [3] => description
    [4] => rich_editing
    [5] => comment_shortcuts
    [6] => admin_color
    [7] => use_ssl
    [8] => show_admin_bar_front
    ...cut...
)
查看以获取有关该函数的更多信息

或者只是调查一下您的
wp\u usermeta

查看每个用户元数据的简单插件: 能够查看每个用户的元数据非常有用,因此让我们为其创建一个简单的插件

以下是用户个人资料/编辑页面的屏幕截图:

下面是代码:

<?php
/**
 * Plugin Name: A Simple User Meta Data Viewer
 * Description: This plugin allows the site admin to view the metadata for each user, in the edit user screen
 * Author:      birgire
 * Version:     0.0.1
 * Plugin URI:  http://stackoverflow.com/a/25316090/2078474
 */

add_action( 'show_user_profile', 'birgire_usermeta_list' );
add_action( 'edit_user_profile', 'birgire_usermeta_list' );

function birgire_usermeta_list( $profileuser )
{
    if( current_user_can( 'manage_options' ) )
    {
        // Fetch all the user meta data for current profile user:
        $items = get_user_meta( $profileuser->ID );

        // Loop:
        $rows = '';
        foreach( $items as $key => $item )
        {
                $rows .= sprintf( '
                        <tr>
                            <th>%s</th>
                            <td><input type="text" value="%s" readonly="readonly" class="regular-text" /></td>
                       </tr>',
                    $key,
                    esc_attr( array_shift( $item ) )
                );
        }

        // Output:
        printf( '<h3>%s</h3><table class="form-table"><tbody>%s</tbody></table>', 
            __( 'User Meta' ),
            $rows   
        );

    }
}

保留条款:您好,谢谢您的回复。我可以问一下,你知道我在哪里可以看到保留wordpress元键的完整列表吗。我很想看看有什么可以使用。我不确定是否存在这样一个元数据密钥的代码表,但我只是在普通安装上浏览了我的
wp\u postemta
表;-)你为什么不给你的元键加前缀呢?啊,对不起,我现在看到你提到的是用户元,而不是post元;-)我将更新答案;-)非常感谢,非常感谢。