Title: Executing php code after sending the form
Last modified: August 22, 2016

---

# Executing php code after sending the form

 *  [agalazo](https://wordpress.org/support/users/agalazo/)
 * (@agalazo)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/executing-php-code-after-sending-the-form/)
 * Hello,
 * I was wondering if it’s possible to execute a PHP code when the user clicks on
   the submit button of the form.
 * The code that I need execute is
    `update_field($field_key, $points, 'user_'. 
   $user_id);`
 * This changes in the bbdd the amount of points that the user have (new field).
 * Thank you in advance 🙂
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [agalazo](https://wordpress.org/support/users/agalazo/)
 * (@agalazo)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/executing-php-code-after-sending-the-form/#post-5418642)
 * Hello again,
 * I tried to use this..
 *     ```
       function descuento_puntos() {
       	//Web service call goes here
       	$user_id = get_current_user_id();
       	$precio_producto = get_field('precio');
       	$puntos_usuario = get_field('puntos', 'user_'. $user_id);
       	$puntos_restantes = $puntos_usuario - $precio_producto;
       	$field_key = 'field_54466d765ea42';
       	update_field($field_key, $puntos_restantes, 'user_'. $user_id);
       }
       add_action('wpcf7_mail_sent', 'descuento_puntos');
       ```
   
 * And I don’t get results. The mail is seeded but the update not. Am I doing something
   wrong?, the update_field() is a ACF (Advanced Custom Files) function, I tested
   it and work perfect, but for some reason I can’t make that It functions since
   Contact Form 7 forms.
 * Sorry, but I’m completely lost. Any help, please?

Viewing 1 replies (of 1 total)

The topic ‘Executing php code after sending the form’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [submit](https://wordpress.org/support/topic-tag/submit/)

 * 1 reply
 * 1 participant
 * Last reply from: [agalazo](https://wordpress.org/support/users/agalazo/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/executing-php-code-after-sending-the-form/#post-5418642)
 * Status: not resolved