需要获取Elementor表单的submission_id,以添加到邮件的引用和内容中。

huangapple go评论50阅读模式
英文:

Need to get submission_id of elementor form to add in reference and content of the mail

问题

I use the elementor pro form for my contact form. I want to add the submission_id to the mail. I want to display the id in the reference header and in the body of the mail. Like a ticket-System.

EXP: New Mail from xxx - ID: 4566334

I tried to use the following code to add a new shortcode, that gives back the submission_id, but ist not working. Is empty and dont have a value:

add_shortcode( 'submission_id', 'get_submission_id' );

function get_submission_id() {
  if ( ! isset( $_POST['form_id'] ) || ! isset( $_POST['_wpnonce'] ) ) {
    return '';
  }

  $form_id = intval( $_POST['form_id'] );
  $nonce_value = sanitize_text_field( $_POST['_wpnonce'] );

  if ( ! wp_verify_nonce( $nonce_value, 'elementor-pro-form-' . $form_id ) ) {
    return '';
  }

  $submission_data = ElementorPro\Modules\Forms\Classes\Form::get_instance( $form_id )->get_submission_data();
  if ( ! $submission_data || ! isset( $submission_data['_id'] ) ) {
    return '';
  }

  return $submission_data['_id'];
}

Any other way to add the submission id from elementor form to the mails?

I tried different plugins, but i dont want to pay for a plugin, just to get the id.

Also tried to add my own shortcode the the function.php, but i doesnt give back a value.

UPDATE: It seems that this part doesnt work

if ( ! isset( $_POST['form_id'] ) || ! isset( $_POST['_wpnonce'] ) ) {
    return 'Error 01';
  }
英文:

I use the elementor pro form for my contact form. I want to add the submission_id to the mail. I want to display the id in the reference header and in the body of the mail. Like a ticket-System.

EXP: New Mail from xxx - ID: 4566334

I tried to use the following code to add a new shortcode, that gives back the submission_id, but ist not working. Is empty and dont have a value:

add_shortcode( 'submission_id', 'get_submission_id' );

function get_submission_id() {
  if ( ! isset( $_POST['form_id'] ) || ! isset( $_POST['_wpnonce'] ) ) {
    return '';
  }

  $form_id = intval( $_POST['form_id'] );
  $nonce_value = sanitize_text_field( $_POST['_wpnonce'] );

  if ( ! wp_verify_nonce( $nonce_value, 'elementor-pro-form-' . $form_id ) ) {
    return '';
  }

  $submission_data = ElementorPro\Modules\Forms\Classes\Form::get_instance( $form_id )->get_submission_data();
  if ( ! $submission_data || ! isset( $submission_data['_id'] ) ) {
    return '';
  }

  return $submission_data['_id'];
}

Any other way to add the submission id from elementor form to the mails?

I tried different plugins, but i dont want to pay for a plugin, just to get the id.

Also tried to add my own shortcode the the function.php, but i doesnt give back a value.

UPDATE: It seems that this part doesnt work

if ( ! isset( $_POST['form_id'] ) || ! isset( $_POST['_wpnonce'] ) ) {
    return 'Error 01';
  }

答案1

得分: 1

我的唯一标识是从日期和时间生成的代码。我在表单中添加了一个隐藏文本字段,然后在高级选项卡中选择了动态数据、页面、当前时间。
您可以设置任何日期/时间格式以及任何字符/单词等。

英文:

My unique id is a code from date and time. I added a hidden text field to the form, then in the advanced tab I selected dynamic data, page, current time.
You can set any date/time format along with any character/word etc..

huangapple
  • 本文由 发表于 2023年2月8日 16:43:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75383188.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定