Jump to content

Recommended Posts

Greetings!

I'm kinda learning php as I go along here (though I do have some experience in other languages), so I'm hoping someone can point me in the right direction.

I'm using an add_action() function in functions.php to access the form data from an Elementor form. Works fine from within add_action(), however I cannot access any of the variables created from elsewhere within functions.php (tried adding a return).

There's probably an easy solution, but I've been wracking my brains all weekend, and haven't gotten anywhere. Any thoughts?

Side Thought: I've also tried do_shortcode(), which does retrieve the information I need, but it seems to modify it somehow, so comparison opperators return as false, even though they are visually equal.

add_action( 'elementor_pro/forms/new_record', function( $record ) {
    $form_name = $record->get_form_settings( 'form_name' );
    if ( 'MyElementorForm' !== $form_name ) {
        return;
    }

    $raw_fields = $record->get( 'fields' );
    $fields = [];
    foreach ( $raw_fields as $id => $field ) {
        $fields[ $id ] = $field['value'];
    }
    $letter_type = $fields['LetterType'];

    // Send Test Email //
    if($letter_type === "1"){
        $message = "Upload";
    } elseif($letter_type === "0"){
        $message = "PDF";
    } else {
        $message = "Fail " . gettype($letter_type) . " " . $letter_type;
    }

    mail(
    "my@email_address.com",
    "Test",
    "Test Message " . $message
    );

    
}, 10, 2);

 

Link to comment
https://forums.phpfreaks.com/topic/313588-accessing-elementor-form-fields/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.