Having trouble creating multi-site plugin for use with sub-sites (6 posts)

  1. davehprohoods
    Posted 2 years ago #

    I am trying to create a plugin where when I go to My Sites > Network Sites, there is a "Network Options" in Settings, and then when I go to a sub-site, there is a "Site Options" in Settings. Also I only want admins to see these options.

    I tried add_action('admin_menu', 'options_admin_actions'); but it does nothing (it worked on our 3.5 installation but not on our 3.5.1 installation). I'm not sure if the complicated documentation I'm reading is accurate as they're all a little different and I'm unfamiliar with most of the functions there.

    Can someone point me in the right direction on this?

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Have you had a look at the Settings_API?

  3. davehprohoods
    Posted 2 years ago #

    This looks really involved... if we want to have a custom page where we just allow someone to modify four settings, is this required? Are there simpler options?

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    is this required?

    Yep. Have a look at http://ottopress.com/2009/wordpress-settings-api-tutorial/

  5. davehprohoods
    Posted 2 years ago #

    Thank you! That's an excellent tutorial. I was getting lost on how to even initiate some of those things.

    However, what I am actually doing (though it might not be necessary or adequate) is moving a plugin from a 3.5 install (which was configured before me) to a new 3.5.1 install and the code to put the menu item in Settings doesn't work, and going to the page itself gives a permissions error. I have no idea how to troubleshoot it as a newbie.

    While it might not be the right way, here's the code if you could give me some advice on it:

    // add feeder options to Settings menu
    function feeder_options_admin_actions() {
    add_submenu_page("Feeder Options", "Feeder Options", 'manage_network', 'feeder-options-admin', 'feeder_options_admin');

    add_action('admin_menu', 'feeder_options_admin_actions');

  6. bcworkz
    Posted 2 years ago #

    Please carefully review the add_submenu_page() documentation. The positioning and usage of each parameter in your example appears to be off. The parameters are NOT the same as for add_memu_page(). Ensure the "Feeder Options" menu page is added before you try to attach a submenu to it. If it does not, you will get strange submenu behavior.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.