• Resolved jdsl79

    (@jdsl79)


    I am using ContactForm7, so once the form is submitted succesfully I redirect the pages to the guestbook, but I want to autocomplete the name in the guestbook using the passed parameters in the URL, is it possibly by using the plugin or I have to hardcoded in the plugin code?

    Thanks in advance

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Marcel Pol

    (@mpol)

    Interesting question 🙂
    I never had this question asked, but it should be possible.
    There are several avenues to take, but it does require PHP programming. The tricky part is the redirect, and how you save/send that data.

    The guestbook plugin uses functions like gwolle_gb_add_formdata and gwolle_gb_get_formdata to save information after a HTTP POST. You could write a hook that uses those functions after the redirect. The field for name is called ‘author_name’.

    An alternative is to write a hook for ‘gwolle_gb_author_name_prefill’. It is documented in /docs/filters/ in the zipfile.

    For the relevant code you can look at frontend/gb-form.php and /functions/gb-messages.php

    Thread Starter jdsl79

    (@jdsl79)

    Thanks a lot for your quick answer @mpol (Marcel), I will take a look over the options.

    Thread Starter jdsl79

    (@jdsl79)

    I finally replaced variable $name by $_GET[‘VAR’] in frontentd/gb-form.php, and it works.

    Plugin Author Marcel Pol

    (@mpol)

    Hi,
    You are much better of using a filter for that. That way your changes won’t get overwritten on an update.

    Thread Starter jdsl79

    (@jdsl79)

    You are right. I guess it is enough for my project, so consider it an option for your future releases, again thanks.

    Plugin Author Marcel Pol

    (@mpol)

    Aha, you might not understand what a filter is. You can add this function to the functions.php of your theme or your own plugin.
    Filters and Actions:
    https://codex.ww.wp.xz.cn/Plugin_API

    function my_gwolle_gb_author_name_prefill( $prefill ) {
            // $prefill is a string
            $prefill = $_GET[‘VAR’]; 
            return $prefill;
    }
    add_filter( 'gwolle_gb_author_name_prefill', 'my_gwolle_gb_author_name_prefill', 10, 1 );
    
    Thread Starter jdsl79

    (@jdsl79)

    😉 you got me! What a crack, thanks a lot.

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

The topic ‘get URL parameters’ is closed to new replies.