What is the recommended way to do this?

4.69K viewsCore
0

After submitting a question, I want to take the user to another page where they will fill out a different form to be submitted. The original form (your question form) can only go through if this second form gets submitted successfully. What would be the best way to do this using Anspress?

Hi everyone…I’m new to anspress and would like to firstly thank the project leader…Rahul, I think, for a job well done so far. Thanks a billion times over! This question should be answered by someone who knows some coding or so please. I need same thing for my site. Want to make it mandatory to fill another form about your school, your department, your course or class during question posting and this form must be filled to have your question successfully submitted. Thanks.

Thanks for the boost @siconet!

1

I think it will be easier to solve your task from front-end.

After user press “submit question”, don’t go to server, just display another set of elements for your user. Internally let it be one whole form. Validate it like you want, and second button would send real server POST, and all “two pages” would go to the server together.

Where they will be validated again and properly stored with your custom logic.

You could probably use this AnsPress feature:

			default:
				/**
				 * ACTION: ap_process_form_[action]
				 * process form
				 * @since 2.0.1
				 */
				do_action( 'ap_process_form_'.$action );
				break;

Thanks @Dima….will try it this weekend. Been busy. Thanks.

Hmm… I was afraid someone would suggest this because the 2nd form is a payment form. I want to use Braintree’s Hosted Fields (an iFrame). It captures user payment info and submits to their servers without ever soiling my servers with sensitive CC info (PCI Compliance and what not).

Then you should have said it in your question.

In this case I would
1. save original question as hidden/draft/some invisible status
2. pass question id to your payment system, redirect user to your payment page https://anspress.io/questions/question/what-hook-can-i-use-to-change-the-redirect-after-posting-a-question/
3. after he have paid, use your payment system default way to understand payment is indeed received, and if it is, change status of associated question to visible.

@Dima, thanks for responding. But I have a slightly different issue please. Like I explained above, and if you can, please help with the exact code or exact step to achieve this. Am really a newbie…so please help!
Like I explained above, I want to make it mandatory to fill another form about your school, your department, your course or class during question posting and this form must be filled to have your question successfully submitted.

This is exactly my own situation. We will have two sections on the site. A free question posting section (where the only requirements will of course be to first be a registered user, and fill the second form with details of your school) and the second section will require you to pay to ask a question. That paid section (on same site) we intend to use an elaborate form builder to add all details and requirements on that single form to be submitted with payments.

So please help with this one on anspress. We are using anspress for the completely free question posting and completely free answer posting. Thanks.

You are viewing 1 out of 1 answers, click here to view all answers.