0

In single WP installations, on a plugin's generated sub-page, you put

<form action="options.php" ...

does the job well.

However, in Multisite Network sub-page, options.php doesnt work, nor settings.php (it redirects to that page after form submission)...

I cant find out what page to use there, to send <form> values to that page which will save and redirect back to the sub-page ( like options.php does on single WP site- it saves values and redirects back).

1

The easiest thing to do is to set the form's action='' and use the global $plugin_page; as described in the Notes section of add_submenu_page().

For example:

add_action ('network_admin_menu', 'add_network_menus') ;

function
add_network_menus ()
{
    add_menu_page ('My Page Title', 'My Menu Title',
        'manage_network', 'my_menu_slug', 'my_network_admin_page') ;
    add_submenu_page ('my_menu_slug', 'Some Subpage Title',
        'My Submeny Title', 'manage_network', 'my_submenu_slug',
        'network_admin_subpage') ;

    return ;
}

function
network_admin_page ()
{
    global $title, $plugin_page ;

    echo <<<EOF
<div class='wrap'>
    <div id='icon-tools' class='icon32'></div>
    <h2>$title</h2>

    <p>more content here</p>
</div>
EOF;

    return ;
}

function
network_admin_subpage ()
{
    global $title, $plugin_page ;

    echo <<<EOF
<div class='wrap'>
    <div id='icon-tools' class='icon32'></div>
    <h2>$title</h2>

    <p>more content here</p>
    <form action='' method='GET'>
        <input type='hidden' name='page' value='$plugin_page' />
        <input type='submit' value='Submit'>
    </form>
</div>
EOF;

    return ;
}

This works for both normal and network admin menus.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.