How to make custom the options.php correctly (3 posts)

  1. ssoulless
    Posted 2 years ago #

    Hi guys, im building a plugin, i have an administration page of this plugin in the settings of my wordpress, in that page i have a form like this

    <form name="frm1" action="options.php" method="POST">
     <!--....... all the form ....... -->
     <input type="submit" value="Save settings" class="button-primary />"

    Well, in the action="" of the form i call the file options.php in orther to show the message "settings saved" when the submit button is pressed.

    I need to catch some values of this form, i can do that just creating another file and change the action="" of the form and get the values for example like this


    But how can i use the options.php for show the "settings saved" message and my custom action at the same time?

    Do i have to copy and paste all the options.php to another file, and then modify it for catch the values that i need????, i can do that... but i think its not a the correct way.

    Thanks for answer.

  2. bcworkz
    Posted 2 years ago #

    Use the functions for Administration Menus to add your admin page. Then use the Settings API to organize your page with sections and input fields. Doing it this way allows the API to semi-automatically handle the saving of settings and the populating of form elements. You do not deal with options.php yourself, the API does this for you.

  3. bcworkz
    Posted 2 years ago #

    Ugh, I had a bad evening remembering how the Settings API actually works, and disseminated some bad details, though the main point of using the API is correct. My corrections in the third post here:
    holds true for your situation as well. My apologies.

Topic Closed

This topic has been closed to new replies.

About this Topic