WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to hook options.php (1 post)

  1. mordamax
    Member
    Posted 2 years ago #

    Hi!
    I set up multi-site and added custom menu page into admin side, and I want to edit options.
    Users of new sites must have an Editor role. So they can't to edit my options, because them can edit only super admin

    $capability = 'manage_options';
    if ( is_multisite() && !is_super_admin() && 'update' != $action )
    	wp_die(__('Cheatin’ uh?'));

    Do anybody know any way to hook the capability of options.php to be able to edit this options.
    Here is the full code.

    add_action('admin_menu', 'mp_change_defaults');
    function mp_change_defaults() {
    
        //create new top-level menu
        add_menu_page('Xxxxx Partners Page Settings', 'Xxxxx', 'edit_pages', __FILE__, 'mp_settings_page', plugins_url('/images/xxxx.png', __FILE__));
    
        //add_submenu_page( __FILE__, 'Xxxxxx Partners Settings', 'Settings', 'administrator', 'mp_settings', 'table');
    
        add_action( 'admin_init', 'register_mp_settings' );
    }
    
    function register_mp_settings() {
        register_setting( 'mp-settings-group', 'partners_twitter' );
        register_setting( 'mp-settings-group', 'partners_linkedin' );
        register_setting( 'mp-settings-group', 'partners_facebook' );
        register_setting( 'mp-settings-group', 'partners_rss' );
        register_setting( 'mp-settings-group', 'partners_website' );
        register_setting( 'mp-settings-group', 'partners_blog' );
    }
    
    function mp_settings_page() {
        ?>
        <div class="wrap">
        <h2><?php _e('Partner Social Links'); ?></h2>
        <form method="post" action="options.php">
        <?php settings_fields( 'mp-settings-group' ); ?>
        <?php //do_settings_fields( 'mp-settings-group' ); ?>
            <table class="form-table">
               <tr valign="top">
                 <th scope="row"> Twitter account link: </th>
                    <td><input type="text" name="partners_twitter" value="<?php echo get_option('partners_twitter'); ?>" style="width: 350px;" /></td>
               </tr>
    
               <tr valign="top">
                 <th scope="row"> LinkedIn account link: </th>
                    <td><input type="text" name="partners_linkedin" value="<?php echo get_option('partners_linkedin'); ?>" style="width: 350px;" /></td>
               </tr>
    
               <tr valign="top">
                 <th scope="row"> Facebook account link: </th>
                    <td><input type="text" name="partners_facebook" value="<?php echo get_option('partners_facebook'); ?>" style="width: 350px;"  /></td>
               </tr>
    
               <tr valign="top">
                 <th scope="row"> RSS account link: </th>
                    <td><input type="text" name="partners_rss" value="<?php echo get_option('partners_rss'); ?>" style="width: 350px;"  /></td>
               </tr>
    
               <tr valign="top">
                 <th scope="row"> Partners website link: </th>
                    <td><input type="text" name="partners_website" value="<?php echo get_option('partners_website'); ?>" style="width: 350px;"  /></td>
               </tr>
    
               <tr valign="top">
                 <th scope="row"> Partners blog link: </th>
                    <td><input type="text" name="partners_blog" value="<?php echo get_option('partners_blog'); ?>" style="width: 350px;"  /></td>
               </tr>
    
            </table>
            <input type="hidden" name="update" value="defaults" />
            <p class="submit">
            <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
            </p>
    
        </form>
    
        </div>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic