• Resolved dpasserone

    (@dpasserone)


    Hi! great plugin.
    I have a shortcode from the tablepress plugin ([table-cell id=10 cell=C3 /])
    and I want to include it into a “select” form tag of CF7

    [select* My_tag “Default value” [table-cell id=10 cell=C3 /] ]

    Unfortunately, I did not get it to work.
    Can you help? Thank you
    Daniele

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Tobias Zimpel

    (@tz-media)

    Hi!

    Thanks a lot!

    Iβ€˜m afraid a shortcode inside of another shortcode (the form field itself is a shortcode syntactically) canβ€˜t work. The shortcode syntax itself does not allow for that.

    What exactly are you trying to achieve? Maybe there is a way to work around this problem.

    Best regards,
    Tobias

    Thread Starter dpasserone

    (@dpasserone)

    Thank you for the prompt reply.
    So: TablePress can deliver short codes for an element of a table:

    [table-cell id=10 cell=C3 /]

    Now, in this table there is a list of courses, one per line.
    Each column has information about the course: level, location, day of the week, etc. and in the last column there is a link to a Registration form.

    The registration form should then include as “mandatory” fields all the data of the line of the course from the table (using [table-cell id=10 cell=XY /] with X ideally taken from the registration link, and Y the column of the level, of the location…) and allow the customer only to fill in the personal data.

    For example, ideally I would like to assign to [level] the value of [table-cell id=10 cell=B1 /], and include [level] in the Email to the site and to the customer…

    I noticed that one can define a CF7 shortcode using php scripting, and this could help, but is a bit complicated…

    Is it clear?
    Thank you for any help in that
    Daniele

    Plugin Author Tobias Zimpel

    (@tz-media)

    Hi Daniele,

    I believe the only way to get the shortcake into the email is the pho scripting version. I’d be happy to provide you with the right php code to include into your functions.php.

    Is it always the same code with id=10 and cell=C3? Or could that change?

    Tobias

    Thread Starter dpasserone

    (@dpasserone)

    It could change. But only the line of the cell
    The rest is quite fixed

    THe table could have a structure like the one here:

    https://limmatsharks.com/schwimmschule/kursdaten-kinder/

    In the last column of line “B”, “C”, “D” there would be a link for the “Anmeldung” to the course “B”, “C”, “D”.
    The link is to one CF7 form. Then the variable passed from the link to the form should barely be the line. Suppose that line=”G” , I imagine that the link to the form could have a parameter telling the form that the line=”G”

    Then your php script should get as an input this line number, and extract cell=G2—> <Gruppe>, then cell=G3—> <Begin> cell=G4—><Wochentag> and so on.

    Hope I am clear…
    Thanks for the help

    Daniele

    Thread Starter dpasserone

    (@dpasserone)

    …and another suggestion from another Tobias, author of TablePress

    “TobiasBg wrote:

    Hi,

    you could use it in PHP code with a trick, by wrapping it in the Shortcode evaluation function:
    $shortcode_value = do_shortcode( '[table-cell … /]' );

    Regards,
    Tobias”

    Plugin Author Tobias Zimpel

    (@tz-media)

    Hi Daniele,

    I believe your problem can’t be solved that easily. The problem is handing the selected course over to the CF7 Form and then making different columns of the table for that course available in the email template.

    Sorry I couldn’t solve your issue here, but this would need some more discussion about what exactly is needed, and probably some custom code / plugin to connect TablePress and Contact Form 7 in the way you would need it, which I’m afraid I can’t provide for free.

    Best regards,
    Tobias

    Thread Starter dpasserone

    (@dpasserone)

    I fully understand.
    But the example with a fixed “C3” element: would it be possible for you to write it here?

    That would be of greatest help!

    Vielen Dank!
    Daniele

    Plugin Author Tobias Zimpel

    (@tz-media)

    Hi Daniele,

    no problem. I even went a step further and wrote you an example code that allows you to target two different columns. You should be able to extend that to your needs. If you need help with that, feel free to contact me here again.

    function my_special_mail_tag( $output, $name, $html ) {
    
        switch ($name) {
            case 'course-3': // shortcode with number
                $output = do_shortcode( '[table-cell id=10 cell=C3 /]' ); // corresponding cell in line C
                break;
            case 'course-4': // shortcode with number
                $output = do_shortcode( '[table-cell id=10 cell=C4 /]' ); // corresponding cell in line C
                break;
        }
    
        return $output;
    }
    add_filter( 'wpcf7_special_mail_tags', 'my_special_mail_tag', 10, 3 );

    With that, you can use [course-3] in your email to target cell C3, for example.

    Best regards,
    Tobias

    • This reply was modified 7 years, 6 months ago by Tobias Zimpel.
    Thread Starter dpasserone

    (@dpasserone)

    Wow! That’s COOL!

    Since you are so kind, a couple of bonus questions… πŸ™‚

    1) I have an extension called “Send PDF with CF7” that allows me to send a CSV file with all tags. Will it also include the special tags (I will try, ok…)?

    2) I was wondering whether the HTML link to the CF7 form could contain a variable as a parameter, and then use it:

    https://limmatsharks.com/schwimmschule/anmeldeformular-online/?mycourse=course-3

    and then

    [#mycourse#]

    would it work or should I put it in the
    “case” directive of the functions.php?

    Plugin Author Tobias Zimpel

    (@tz-media)

    Hi Daniele,

    1) I’m afraid it won’t, since I hack into CF7 to interpret them, but they are not officially known to CF7. But you should probably try it yourself.

    2) No, the html parameter is not present anymore when sending the form, so it can’t be used in the email. It would have to be present as a form field in the first place to be available when sending the email. And that’s where it all began…

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

The topic ‘Including a shortcode INTO a form tag’ is closed to new replies.