WordPress.org

Support

Support » How-To and Troubleshooting » [Newbie] a function who send the request to another page

[Newbie] a function who send the request to another page

  • jeanchristophe
    Member

    @jeanchristophe

    Hello,

    I want to make a function which send me to an another php file.

    My problem is that if I use include_once, then it is shown both in 110101_plugin-page.php AND add_workarea.php!
    If i use “location in sted, then I receive an error.

    [CODE]
    add_menu_page (‘Medarbejder Plugin’, ‘Medarbejdere’, ‘administrator’, __FILE__, ‘_menu_page’, plugins_url (‘/images/wordpress.png’, __FILE__));
    add_submenu_page (__FILE__, ‘Håndtere’, ‘Medarbejdere’, ‘administrator’, __FILE__, ‘_menu_page’);
    add_submenu_page (__FILE__, ‘Tilføje’, ‘Tilføje’, ‘administrator’, __FILE__, ‘_add_elements’);

    function _menu_page() { include_once(“110101_plugin-page.php”); }
    function _add_elements_about_employees(){ include_once(“add_workarea.php”); }

    [/CODE]

    Do you know how I can solv this?

    One extra question:
    Which kind of function is it possible to add to add_menu_page when there is no interface? (just to get some new ideas!)

    Best regards
    Jean-Christophe

Viewing 2 replies - 1 through 2 (of 2 total)
  • jeanchristophe
    Member

    @jeanchristophe

    If I try with:
    [CODE]function _menu_page() {header(“location: 110101_plugin-page.php”);}
    [/CODE]
    I got
    [CODE]
    Warning: Cannot modify header information – headers already sent by (output started at /var/www/web15/web/wordpress/wp-admin/menu-header.php:152) in /var/www/web15/web/wordpress/wp-content/plugins/110112/110112.php on line 101
    [/CODE]

    Any idea about how to solve my problem?

    Best regards
    Jean-Christophe

    k_nitin_r
    Member

    @k_nitin_r

    Jean,

    You cannot use the add_submenu_page to send a redirect because a part of the page has already been sent to the browser making the request.

    This is by-design (I had saying this statement just as much as you hate reading it). It is the way the API works so you just have to find an alternate way to do what you want to do.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Newbie] a function who send the request to another page’ is closed to new replies.