WordPress.org

Ready to get started?Download WordPress

Forums

[Newbie] a function who send the request to another page (3 posts)

  1. jeanchristophe
    Member
    Posted 3 years ago #

    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

  2. jeanchristophe
    Member
    Posted 3 years ago #

    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

  3. k_nitin_r
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.