• Resolved danielkoch95

    (@danielkoch95)


    Hi,
    i programmed special function, that takes trial keys out of DB and show them in custommers email. I would like to ask, if is it possible to somehow get my special tag called [trial-klic] to google sheets?
    Snippet of the code looks like this:

    add_filter('wpcf7_special_mail_tags', function($output, $name, $html) {
        if ('trial-klic' == $name) {
        $conn = new mysqli("localhost","db","db_pw","db_name");
        $query = "SELECT * FROM  "table" ORDER BY Key DESC LIMIT 1";
        $result = mysqli_query($conn, $query);
        $row = mysqli_fetch_assoc($result);
        $data = $row['Key'];
        $sql_del = 'DELETE FROM table ORDER BY Key DESC LIMIT 1';
        mysqli_query($conn, $sql_del);
        mysqli_close($conn);
            return $data;
        }
        return $output;
    }, 10, 3);
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author westerndeal

    (@westerndeal)

    Hi @danielkoch95,

    If you have used [trial-klic] tag while creating your contact form than surely this data would be fetched to your google sheet.

    Let us know if there is any issue.

    Thanks

    Thread Starter danielkoch95

    (@danielkoch95)

    Hi,
    that was the first i tried, thats why i posted this question and attached my custom code. This solution doesn′t work and i would like to ask, if there is any workoaround.
    Thanks

    Thread Starter danielkoch95

    (@danielkoch95)

    Hi @westerndeal,
    please, do you know, how should i rewrite my function to be compatible with your plugin?
    Thank you in advance.

    add_filter('wpcf7_special_mail_tags', function($output, $name, $html) {
        if ('trial-klic' == $name) {
        $conn = new mysqli("localhost","db","db_pw","db_name");
        $query = "SELECT * FROM  "table" ORDER BY Key DESC LIMIT 1";
        $result = mysqli_query($conn, $query);
        $row = mysqli_fetch_assoc($result);
        $data = $row['Key'];
        $sql_del = 'DELETE FROM table ORDER BY Key DESC LIMIT 1';
        mysqli_query($conn, $sql_del);
        mysqli_close($conn);
            return $data;
        }
        return $output;
    }, 10, 3);
    Plugin Author westerndeal

    (@westerndeal)

    Hello,
    Actually found 1 simple mistake, in your above code,
    Modify with underscore because special mail tags must be written with underscore before tagname.
    if (‘_trial-klic’ == $name) {

    Now, you will get email with values, but this version of CF7 Googlesheet is not compatible with custom special mail tag.
    We are working on the same, so we expect to update with the new version soonest as possible, then you can use this feature.
    Let me know if anything else where i can help you.

    Thanks
    Abdullah

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom mail tags’ is closed to new replies.