• Hello! Sorry if this is a silly question or if I am not asking it in the proper forum.

    I am trying to create a simple plugin which creates some custom REST API endpoints, stores the data created there in a custom database table and shows the results based on some filters in the admin panel. What I am struggling with is the admin panel part. I have tried Googling about how to create the admin page, but every article I have found is about using the Settings API to create a CRUD functionality. What I would need is a form which allows the admin to put in some information, a submit button, and a custom function which will render the page after the submit happens, querying and showing the data.

    Specifically, I would like to find which event/hook to use to be able to read the data from the form, but instead of saving those in the database, I would like to render a table and show it on the same page where the form is.
    Could you please point me in the right direction?

    Thank you in advance!

Viewing 1 replies (of 1 total)
  • Almost every plugin that makes an admin page does this. They are not all doing Settings on their pages.

    Use add_action( 'admin_menu', 'my_plugin_add_admin_menu' ); to make a menu item (which includes a function to call to render the page) and checking for the page to see if you should load scripts.
    In your form, you don’t have an action, so it defaults to the same page, and use method="post". Then use hidden inputs with your plugin parameters that you check for, and the nonce, and of course uses the current value of the inputs to output.
    Use add_action( 'admin_init', 'my_plugin_admin_init' ); to check for your $_POST parameter and set up for what its value indicates.

    Directly in your plugin file (not in a function), check for your $_POST parameter, and you can use add_action( 'init', 'my_plugin_handler_for_parm' ) for direct output like downloading a file.

Viewing 1 replies (of 1 total)
  • The topic ‘Creating Custom Non-Settings Admin Page’ is closed to new replies.