Hi,
I learnt from following FAQ about how to create and implement custom forms –
https://anspress.io/resources/faq/anspress-form-and-validation-api/
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?
- Is there any way to reset the all fields values at once?
- 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 –
https://gist.github.com/atultiwari/4bc9fd36c5fb2a18081762189fd6a347
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 –
- In the end of function “at_custom_question_form_in_ap”
- In the end of function “at_submit_question_form”
- 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’] );
Thanks.
Regards
I use Grammarly, and there are millions of people that do the same. It is a browser extension that will underline spelling and grammar mistakes, then you hover your mouse over the mistake, a little box appears above with the suggested correction, when you click on a correction it makes the modal and everything you just wrote, disappear.
There needs to be a way to not have the modal disappear like that so easily.
when inside a question, the menu display of my site is superimposed on all other pages. what can I do?
Rahul – is there any facility to enable users to edit their profile on anspress.io ? For example, there are a number of things I would like to change, but cannot see anywhere this is enabled.
Thanks
Hi – is there any function that can override the voting icons ? I copied /includes/votes.php to /mytheme/anspress/includes/votes.php to make changes, but this doesn’t seem to work.
Any pointers ?
Thanks
Hi,
I tried to insert question programmatically, like you mentioned in your FAQ. In fact, I used almost the same sample code you provided (except that I changed Tag Id and names).
Unfortunately it threw me an error.
Link to my sample gist –
https://gist.github.com/atultiwari/2f0a877e9e63c0c4ed334ecf50189308
I have already downloaded the latest one from master branch (and confirmed that manual mode etc are there).

Similarly I tried to post answer, it threw me error – “the server responded with a status of 500 (Internal Server Error)”‘
Link to Gist file –
https://gist.github.com/atultiwari/a7c5cfb43324b08125a2cbec6bd15a02
Answer is getting posted with –
$post_id = wp_insert_post($values);
but not with Hook.
I tried to look for where am I making mistake for hours now, but I am unable to figure it out.
Edit 1 –
After the fixed pushed by @Rahul, questions are getting inserted programmatically, as described. However still there are some issues, such as –
- Tags are not getting inserted (I tried to find out if it’s with me only or it’s an issue with the script, but I couldn’t), while question and category is inserted correctly
- Question metas and activity didn’t get inserted when using sample code provided in FAQ –>I think it’s because of
$qametawas never used. I found these working if I use the functions “ap_insert_qameta” and “ap_update_post_activity_meta” on$qameta, however I am not sure if I am using the correct method. - When trying similar method to insert Answer, it didn’t insert
post_parentand answer got orphan. While reading the source code for Answer form and related submit function, I observed that herepost_parentis passed under the variable named$question_id, so I tried to pass it like this, but still it failed.var_dumprevealed that while passing the value for$question_idit’s storing them in array, first is boolean and in 2nd one it’s strong theparent_postid, which is never used. While if we use the same function on default answer form (when answering the question from GUI),$question_idstores the parent post id. How? I couldn’t understand it. - Even if submitting answer programmatically started working, it will also need some metas and activity update for answer as well to complete the all steps.
- I think in complete source section of the FAQ line 15 you forgot to put
;therefore it’s not working at all (out of the box)
Regards,
Atul
Currently there isn’t a way to change the question permalink, but I would really like to. I find that people as their question wrong, and as I respond to questions, I want to improve the question and edit the permalink.
Can you enable this?
If someone leaves a question, and moderation is on, it’s an anonymous post, this is what it shows. That’s pretty bad if you ask me, kills the mood. Instead, there should be a redirect option to a specified page. That would be much smoother and expected, versus this.
I would love to redirect to a thank you page, or an opt-in page, something, anything is better than this.
CANT POST IMAGES HERE, DOESN’T ACCEPT THEM
2 times now I have tried to post a question where I have inserted an image here in the editor. It just sits there after clicking on the submit button.
See https://www.dropbox.com/s/k623b905s3cvofa/Screenshot%202017-11-27%2015.02.10.png?dl=0
Also, I am logged in, but under the button, it says I am not logged in.
The code you have given is of no use. It is very important for SEO as opposed to your assumptions. I suffer from loss of users since the registered pages on Google have changed.
I constantly lose users.
I continue to lose users since it does not send “solved” message. The “solved” message attracts the attention of users.
The site headline must include “solved” message as in the past!
Otherwise, the new add-on is of no use!
Why did you arbitrarily remove this feature which is actively available among options? I expect you to find a clear solution to this problem!