WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to execute a shortcode after the user will press the submit button. I am using Contact form 7 and have inserted the form by a shortcode in the Post edit section.

It's basically a form collecting data and after submit, I will redirect the user to PayPal in a new window. The shortcode for the PayPal button works already on it's own.

I have tried this function but the form seems to get stuck, I get the loading icon forever, the message is delivered but most important, it's not executing my shortcode. Not even a simple echo "test";.

add_action ('wpcf7_mail_sent', 'after_mail_sent');
function after_mail_sent () {
  echo do_shortcode ('[book]');

Any ideas please?

share|improve this question

closed as off-topic by kaiser Jul 28 '14 at 14:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

Conform that shortcodes is working or not. – ayyan Mar 6 '12 at 13:10
The shortcode is working by itself, if I do [book] in page edit, it does show up on my page. I just don't know how to edit the functions file of that CF7 to load my shortcode. Update => I do get the email even if I am not shown the "success" message, by using that function, but what's in the function doesn't show up. – C D Mar 6 '12 at 13:19
I've also realised that I will have to hide the submit button before showing the button from my shortcode.. grr, this is getting worse :/. – C D Mar 6 '12 at 13:23
The code for the [book] shortcode would help. – s_ha_dum Jun 13 '13 at 15:43
that wouldn't have been of any help, I've already mentioned the shortcode is working fine; it's content is irrelevant given the question – C D Jun 15 '13 at 20:28

You could customize Contact Form 7 so that once the button is pressed, it leads to a page where you have your shortcode. You basically are making the a page that should be a confirmation just have your shortcode.

This thread has the info on the redirect: http://wordpress.org/support/topic/plugin-contact-form-7-redirect-to-thank-you-page-on-submit?replies=23

share|improve this answer
Link only answers are discouraged. If something happens to that link the answer becomes useless. Please try to make your answer here stand alone. – s_ha_dum Jun 13 '13 at 14:51
Thanks for the heads up. – Shaan Singh Jun 13 '13 at 15:35
"I need to execute a shortcode after the user will press the submit button.". This is what I needed. – C D Jun 15 '13 at 20:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.