• Resolved rafaelzrt

    (@rafaelzrt)


    Hello,

    the plugin is very interesting and the GUID field is very useful.

    However, is there an option to create a GUID with a pattern?

    I would like to use a simpler GUID, like a sequential number. For example, 001, 002, 003.

    Or have a pattern that doesn’t change. For example, support-001, support-002, support-003.

    Or have a pattern with something dynamic, like the year or date. For example, 2026-001, 2026-002, 2026-003.

    I haven’t found any option for this field in the documentation. Perhaps this would be an interesting update for this field.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    This is a great idea! I already have a GUID shortcode, but I can update it to include attributes so you can prefix it as you wish.

    I also like the idea of a serial number shortcode (the incremented counting) with optional prefixes, suffixes, or other patterns.

    I’ll include these ideas for a future update.

    For now, do you need help with creating a custom code snippet for one you need specifically?

    Thread Starter rafaelzrt

    (@rafaelzrt)

    That is great, I will look forward for your next updates on the plugin.

    I do need help, right now I still dont have a solution for this field to generate a sequential ticket for the form. Other plugins I tested didn’t achieve this successfully. Is it possible or do you have any solution with your plugin?

    Thank you.

    If you’re using a plugin to capture form submissions, you might already have access to one.

    With Flamingo version 1.5+, you can use [_serial_number] in your mail templates, “This tag is replaced by a numeric string whose value increments, so this tag can work as the serial number of each submission”

    Otherwise, you’ll need to track the number of form submissions yourself. First, you’ll need to increment the count and save it upon each form submission, then replace a custom placeholder mailtag with that value in the email.

    We could do it like this:

    In your mail template(s), add an arbitrary placeholder like this:

    Serial: [serial_number]

    You don’t actually need to create a custom form tag for this, and in fact, you probably shouldn’t since the value gets calculated only after a submission was successful. You don’t want to count the ones that end up in spam, right?

    Then in a code snippet, we could do it like this:

    /**
    * Custom Email Behavior on Contact Form 7 Form Submission
    *
    * @param WPCF7_ContactForm $contact_form The current contact form.
    * @param bool $abort If the submission is being aborted.
    * @param WPCF7_Submission $submission The current submission data.
    *
    * @return void
    */
    function au_save_serial($contact_form, &$abort, $submission)
    {
    // Get the form's current count
    $count = (int)get_post_meta($contact_form->id(), '_submission_count', true);

    // Increment it
    $count++;

    // Save it back to the form
    update_post_meta($contact_form->id(), '_submission_count', $count);


    // Format it
    $serial = sprintf('support-%s-%03d', date('Y'), $count); // E.g. "support-2026-001", "support-2026-002", etc.

    // Replace the placeholder in the email with the formatted value
    $mail = $contact_form->prop('mail'); // Get the first mail property
    $mail['body'] = str_replace('[serial_number]', $serial, $mail['body']);

    // Don't forget the second email!
    $mail2 = $contact_form->prop('mail_2'); // Get the second mail property
    if ($mail2['active']) {
    $mail2['body'] = str_replace('[serial_number]', $serial, $mail2['body']);
    }

    // Set the mail properties with the updated values
    $contact_form->set_properties(array(
    'mail' => $mail,
    'mail_2' => $mail2
    ));
    }
    add_action('wpcf7_before_send_mail', 'au_save_serial', 10, 3);

    Now this could certainly work, but there are a few drawbacks to this. For one, if more than one submission was submitted simultaneously, you could get duplicate serial numbers (it’s often why I go for the GUID approach!). Secondly, if you’re storing submissions anywhere, the serial number here is not saved alongside the submission.

    If either of those things are dealbreakers, let me know and I can give you a more robust snippet to use.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.