WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. ssoulless
    Member
    Posted 1 year 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 />"
    </form>

    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

    $_POST['checkboxValue-forExample'];

    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
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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:
    http://wordpress.org/support/topic/cannot-save-checkboxes-values-in-option-page?replies=2
    holds true for your situation as well. My apologies.

Topic Closed

This topic has been closed to new replies.

About this Topic