How to retrieve data from Wordpress Elementor formular sent via Webhook to shortcode?

68 views Asked by At

Using: Wordpress, Elementor, PHP

What I am trying to do: When users are filling out the formular (created from Elementor) with name, email etc., then a custom post is created (type called: tilmeldinger). This is working as intended, see code example below. However, the $atts does not seem to pass any data, or am I not extracting the data correct?:

function wpc_elementor_shortcode_test( $atts ) {
  $atts = shortcode_atts(
    array(
      'name' => '',
      'email' => '',
    ),
    $atts
  );

  $name = $atts['name'];
  $email = $atts['email'];

  $new_post = array(
    'post_title' => $email,
    'post_content' => $email,
    'post_type' => 'tilmeldinger',
    'post_status' => 'publish',
  );

  $post_id = wp_insert_post( $new_post );
}
add_shortcode( 'my_elementor_test', 'wpc_elementor_shortcode_test' );

Illustration of the form formular:

Illustration of the form formular

The name field:

The name field

The webhook and shortcode:

The webhook and shortcode

0

There are 0 answers