英文:
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..
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论