• Resolved chaklesh

    (@chaklesh)


    Hello Devs, I am creating a plugin. But I stuck when processing the Form data using the hooks. The hook function xyz_view_mobile_form_submit() call of submenu giving the html content in whole webpage breaking the structure of wordpress. When the same html content is loaded in the submenu page content function xyz_fill_mobile_search() i.e. without hook function it shows as normal. The code is given below:

    function xyz_dash_view_mobile(){
        $hookname = add_submenu_page( 
            'xyz_dash_option', //parent slug
            'xyz Dasboard View Mobile',// sub menu page <title>Title</title> 
        'View Mobile', // sub menu link text
        'manage_options', // capability to access the page
        'xyz_view_mobile', // page URL slug
         'nyag_fill_mobile_search', // callback function to show page content
         'dashicons-star-half', // menu icon
         3 // priority
         );
         add_action( 'load-' . $hookname, 'xyz_view_mobile_form_submit' );
    }
    //now Register submenu to Main Menu
    add_action('admin_menu', 'xyz_dash_view_mobile');
    //hooked function to process form data 
    function xyz_view_mobile_form_submit()
    {
        include_once( 's_mob_view.php' ); //This function content causing issue
    }
    //To Show Fill Data Page
    function xyz_fill_mobile_search()
    {      
        include_once( 'm_search.php' ); //include as php/html data file
    }

    P.S.- I am Newbie in wordpress Devlopment, Sorry if I forgot to explain clearly. Let me know if any problem in question ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    AFAIK, we wouldn’t normally use submenu hooks any more. At least I never have. I believe it remains only for reverse compatibility. What I have always done is include any form submit handling within my page’s submenu callback function. Use $_SERVER['REQUEST_METHOD'] to conditionally decide whether to present the form or process the submittal.

    Thread Starter chaklesh

    (@chaklesh)

    Thank You dev, The issue is resolved. Thanks for your support. WordPress is ?.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin Form Processing hook content formating issue’ is closed to new replies.