• 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://www.ads-software.com/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • Thread Starter agalazo

    (@agalazo)

    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.