WordPress.org

Ready to get started?Download WordPress

Forums

admin backend: show page inside admin area (2 posts)

  1. Pospiech
    Member
    Posted 4 years ago #

    I am developing a plugin, that can edit values in a database. The plugin is showing pages in the backend to manage the content. I have a problem to show a page after an action of a form. The basic structure is this:

    if (isset($_POST['form_action_Show'])) {
        show_seminare();
    }
    if ($_POST['form'] == "SeminarEditSelect") {
        show_seminar_edit();
    }
    
    function show_seminare() {
        echo "<div class=\"FormDivSeminare\">";
        echo "<h3>Seminare</h3>";
        echo "<form name=\"form_editseminar\" method=\"post\" action=\"".action_page()."\" >\n";
        echo "<input name=\"form\" value=\"SeminarEditSelect\" type=\"hidden\" />\n";
    
    ...
    }
    
    // Adminmenu Optionen erweitern
    function add_menus() {
        add_menu_page('Seminare Verändern', 'Seminare', 8, __FILE__, 'show_seminar_main');    
    
        add_submenu_page(__FILE__, 'Seminare Anzeigen', 'Anzeigen', 8, 'show_seminare', 'show_seminare');
    }

    If I try to edit a seminar via the button 'SeminarEditSelect', the function 'show_seminar_edit()' is called. But the output is NOT inside the backend, it is above everything, even above the html-header.

    So it is completely wrong. How solve this simple error?

  2. s_ha_dum
    Member
    Posted 4 years ago #

    Is this your main plugin file? If it is, those if switches are going to run as soon as the plugin initializes, which is why your function echoes content above everything else. You need to call that function at the place in the code where you want it to show up.

Topic Closed

This topic has been closed to new replies.

About this Topic