首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编辑器角色未保存自定义post类型的设置页

编辑器角色未保存自定义post类型的设置页
EN

WordPress Development用户
提问于 2017-05-25 15:58:22
回答 1查看 1.7K关注 0票数 2

我现在有一个定制的post类型,通过add_submenu_page有一个子菜单页面。在这个页面上,我有一个带有一些基本设置的表单,比如文本编辑器和一些单选按钮。

代码语言:javascript
复制
function programme_enable_pages() {
    add_submenu_page(
        'edit.php?post_type=programmes',
        'content',
        'Archive content',
        'edit_pages',
        basename(__FILE__),
        'archiveContent'
    );
}
add_action( 'admin_menu', 'programme_enable_pages' );

function register_programme_settings() {
    register_setting( 'programme_content', 'programme_content' );
    register_setting( 'programme_content', 'programme_branding' );
}
add_action( 'admin_init', 'register_programme_settings' );

function archiveContent() { ?>
<div class="wrap">

    <form method="post" action="options.php">
        <?php
        settings_fields( 'programme_content' ); 
        do_settings_sections( 'programme_content' );

        wp_editor(
            get_option( 'programme_content' ),
            'programme_content',
            $settings = array(
                'textarea_name' => 'programme_content'
            )
        ); ?>

        <label><b>Branding options</b></label><br>
        <input type="radio" name="programme_branding" id="branding_blue" value="blueBranding" <?php checked('blueBranding', get_option('programme_branding'), true); ?> checked="checked">Blue Branding<br>
        <input type="radio" name="programme_branding" id="branding_red" value="redBranding" <?php checked('redBranding', get_option('programme_branding'), true); ?>/>Red Branding<br>
        <input type="radio" name="programme_branding" id="branding_orange" value="orangeBranding" <?php checked('orangeBranding', get_option('programme_branding'), true); ?>/>Orange Branding

        <?php submit_button(); ?>   
    </form>     
</div>
<?php }

当具有管理员角色的用户编辑任何内容并保存更改时,内容将无问题地保存。但是,当具有编辑器角色的用户保存更改时,它们将被定向到一个页面,该页面声明:

对不起,不允许您管理这些选项。

有谁能帮我指出正确的方向,告诉我如何让用户角色的编辑器保存这些选项?

EN

回答 1

WordPress Development用户

发布于 2017-06-06 16:18:41

为了保存选项,用户需要具备编辑器所缺乏的manage_options功能。

在菜单中使用edit_pages功能,编辑器可以访问管理页面,但是设置submit的选项处理程序代码没有考虑到管理页面的上下文。

怎么修?我想说,除了管理员之外,没有人能够更改站点范围的设置,所以您的方法是错误的.更有建设性的选择是不使用设置API并自己处理表单提交,或者使用角色管理器类型的插件来赋予用户manage_option功能。

票数 -1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/268111

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档