How to reset custom form fields values after submission?

3.82K viewsGeneralfields


I learnt from following FAQ about how to create and implement custom forms –


I tested the demo form provided in the tutorial and it’s working as expected. However the form retains the fields values after the form is submitted. I am unable to figure out how to reset form fields values?


  1. Is there any way to reset the all fields values at once?
  2. What if I just want to reset any particular field value (for e.g. if I only want to reset Editor field in sample form of above FAQ). [I am particularly interested in this one.]

Edit 1-

As I have posted gist for inserting question programmatically –


In that only for testing purpose, I posted a sample custom form with the help of FAQ, I am still unable to figure out how to reset fields entries after submission. Please look into this?

Edit 2 –

I did try the answer posted by Rahul, but unfortunately it didn’t unset. Maybe I didn’t understand some part properly.

@rahul, can you please little bit elaborate. For e.g., my customized form name is – “at_question_form” (with two fields named “post_title” and “post_content”), so I used following code –


unset( anspress()->forms[’at_question_form’] );


Since it didn’t unset out of the box, I thought of all possible places where I could have used this code –

  1. In the end of function “at_custom_question_form_in_ap”
  2. In the end of function “at_submit_question_form”
  3. And soon after generating this form

But, neither of them could unset the form.

So please help me out with this.

Also is there anything like (unset only specific field)-

unset( anspress()->forms[’at_question_form’][’post_content’] );




edited question

Hello Dr. Atul,

Doing it is a piece of cake:

unset( anspress()->forms[’question’] );

Check source code hereĀ AnsPress::get_form().

commented on answer

Unfortunately it didn’t work for me. I have updated my question with the sample form name and field names. Please go through that again . Thanks.