skip to Main Content

Each form submission in Elementor gets assinged a unique ID that gets iterated by one for each new submission. I want to reference this ID in the Actions after submit – E-Mail as a way of letting the user know the ID of their request. Is there any way of including this ID as a shortcode in the email that gets sent to the user, to create some sort of ticketing system?

I tried to add the following but it didn’t work: [field id="submission_id"]
I also read [these]https://elementor.com/help/customizing-form-emails/) Elementor Docs, but they are not very helpful with what I’m trying to achieve.

I think that this requries some custom coding, but I’m unsure where to start.

2

Answers


  1. Chosen as BEST ANSWER

    I found an easy solution for this. I created a short code, that queries the DB table where the submission IDs are stored, extracts the highest value, adds one and returns the value. I then use this short code in the email template that gets sent to the user, and it displays the corresponding submission ID in the E-Mail.

    Here is the shortcode:

    // Register a function to run on the init hook
    add_action( 'init', 'register_get_submission_id_shortcode' );
    
    function register_get_submission_id_shortcode() {
        // Register the get submission id shortcode
        add_shortcode( 'get_submission_id', 'get_submission_id' );
    }
    
    function get_submission_id() {
        global $wpdb;
    
        // Get the highest value from the database table
        $sql = "SELECT MAX(ID) as max_id FROM `hleKsJ9_e_submissions`;";
        $result = $wpdb->get_var( $sql );
    
        // Add 1 to the highest value and return it
        if ( $result ) {
            return  $result;
        } else {
            return 'No results found';
        }
    }


  2. Tobias! I have the same problem with the Form ID, but I coudn’t make this shortcode work. Can you help me? I added it into the form as a hidden shortcode item but it simply doesnt work. I used the id of job_id and in my HTML template called it like:

    Job ID: [field id="job_id"]

    . The problem is, in my e-mail, the code is shown, not the max id hehe

    E.g.: Job ID: // Register a function to run on the init hook add_action( ‘init’, ‘register_get_submission_id_shortcode’ ); function register_get_submission_id_shortcode() { // Register the get submission id shortcode add_shortcode( ‘get_submission_id’, ‘get_submission_id’ ); } function get_submission_id() { global $wpdb; // Get the highest value from the database table $sql = "SELECT MAX(ID) as max_id FROM wp_e_submissions;"; $result = $wpdb->get_var( $sql ); // Add 1 to the highest value and return it if ( $result ) { return $result; } else { return ‘No results found’; } }

    Thanks!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search