Piklist入门教程十三:checkbox,dropdowns,radio控件显示用户信息

我们可以在Piklist的checkbox、dropdowns、radio控件显示用户信息,可以在Piklist创建的Metabox、Settings、Widget中显示,这些控件中的’choices’属性用到wordpress函数的 get_user() 该函数将所有用户返回为数组对象来处理,代码如下:

piklist('field', array(
    'type' => 'select'
    ,'field' => 'my_users'
    ,'label' => 'Choose a user'
    ,'choices' => piklist(
        get_users(
            array(
                'orderby' => 'display_name'
            ,'order' => 'asc'
            )
            ,'objects'
        )
        ,array(
            'ID'
        ,'display_name'
        )
    )
));

预览效果:(记得把type改改其他radio checkbox控件)

get_user_sel

radio:

get_user_radio

checkbox:

get_user_check

文章分类 Piklist, 经验分享 标签: ,

发表评论


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /var/www/wp/code/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048