Timeline for How to save custom settings api fields with custom section fuction
Current License: CC BY-SA 4.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 1, 2020 at 18:44 | vote | accept | Atif Aqeel | ||
Jul 1, 2020 at 18:44 | comment | added | Atif Aqeel | Thank you. and can you please have a look of the question i asked? | |
Jul 1, 2020 at 18:40 | comment | added | Sally CJ | Alright then. Good luck. | |
Jul 1, 2020 at 18:21 | comment | added | Atif Aqeel | if the page settings were different , form will not save the data but actually it is saving. the only thing error is not showing. but i really dont care about it because i want to save data by ajax. | |
Jul 1, 2020 at 18:12 | comment | added | Sally CJ |
And are you sure the settings page slug is actually theme_amna ? Did you try my sample plugin? Did it work?
|
|
Jul 1, 2020 at 18:09 | comment | added | Atif Aqeel | error notification mean, settings_errors( 'theme_amna' ); this is not longer showing the success message, dont know why. and here is the question asked for ajax wordpress.stackexchange.com/questions/370176/…. | |
Jul 1, 2020 at 17:42 | comment | added | Sally CJ | "error is not longer working" - what error? But I've already given you a sample plugin that should work in that the fields are being saved properly, so about the AJAX, please ask that in another post. However, do take time to read the documentation in the plugin developer handbook and/or the REST API handbook before asking your question. | |
Jul 1, 2020 at 17:19 | comment | added | Atif Aqeel | Thank you, just update the settings_fields( 'amna-fields-group' ); and options.php that work fine. but error is not longer working. can you just help me how can i submit fields data by ajax? | |
Jun 30, 2020 at 15:16 | comment | added | Sally CJ | See the revised answer and try the sample plugin. I hope that helps? | |
Jun 30, 2020 at 15:10 | history | edited | Sally CJ | CC BY-SA 4.0 |
Better answer
|
Jun 30, 2020 at 12:55 | comment | added | Atif Aqeel | if you click on save changes button settings fields and settings section will not find the update_options function because update options was called and attached with save changes buttons, same as the error_message();. so you will have to write the functions for both of it. | |
Jun 30, 2020 at 12:13 | comment | added | Sally CJ |
Well, you're just changing the table to div and the rest should still follow the settings API methods like calling settings_field() and submitting to options.php so that you would not need to manually call update_option() . That's what I mean by "proper". After all, the amna_do_settings_sections() already calls amna_do_settings_fields() , so why call it manually? Settings fields should belong in their own settings section, no?
|
|
Jun 30, 2020 at 11:27 | comment | added | Atif Aqeel | This is not the response of my question. my question was , i have write the custom code for do_settings_fields and do_settings_sections functions. In this case we dont need to call options.php but the function should submit the data on save changes button. So need to write the code for save changes button. | |
Jun 30, 2020 at 9:39 | history | answered | Sally CJ | CC BY-SA 4.0 |