• Resolved andywt

    (@andywt)


    I would like to have a menu page that captures information for me to customize a contact form db shortcode. After capturing the variables, I would pass the variable on thru the url that calls my WP page which in turn contains the shortcode.

    I have been successful in getting the variables passed to the WP page, but have had no success in using variable in place of hard-coded values in the shortcode.

    Any suggestions?

    https://wordpress.org/plugins/contact-form-7-to-database-extension/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    Thread Starter andywt

    (@andywt)

    Mike,
    This is exactly what I am looking for but maybe I’m, missing something as it is not working.
    Here is my url:
    http://www.prosperrotary.org/flags/missing-flags-test/?routex=1, I also tried using the shortlink: /flags/?p=1086&routex=1 but the url gets rewritten to the permalinked version above.

    Here is my shortcode:
    [cfdb-datatable form="2015 Flag Database" edit="true" orderby="Neighborhood,Route,Street,House #" show="Submitted,First Name,Last Name,Phone,Email,Neighborhood,House #,Street,Route,Method of Payment,Flag Lease Quantity,Were you a customer last year?,payment_status" filter="Route=$GET(routex)"]

    If replace the filter with:
    filter="Route=1"]
    I get the expected list.

    I updated my contact-form db to v2.9.14, contact-form-db-editor v1.4.1, but no change. Any ideas?

    Plugin Author Michael Simpson

    (@msimpson)

    filter="Route=$_GET(routex)"

    Thread Starter andywt

    (@andywt)

    duh. Thanks that did the trick!!

    Thread Starter andywt

    (@andywt)

    is this implemented with the cfdb-export-link function?

    Plugin Author Michael Simpson

    (@msimpson)

    Like this?
    [cfdb-export-link form=”form name” filter=”Route=$_GET(routex)”]

    That will generate a link with the $_GET in it on the page where the shortcode is placed. But it doesn’t process any URL parameters from that page. When you click the link, it will process URL parameters. So it won’t work the way I think you mean it.

    Thread Starter andywt

    (@andywt)

    That was my experience. It processed the command with an undefined variable for the Route. Is this something that can be fixed to work like it does in the cfdb-database or just not possible?

    Plugin Author Michael Simpson

    (@msimpson)

    Short answer: I created a fix. Would you test the development version of this plugin?
    (uninstall the plugin, then install the .zip file from this link)

    TL;DR

    If you have a page url like
    http://example.com/?p=1&routex=abc

    and on that page you have the short code:
    [cfdb-export-link form="form name" filter="Route=$_GET(routex)"]

    Then viewing that page with the “routex=abc” in the URL should display “Export” with a link something like:
    http://example.com/wp-admin/admin-ajax.php?action=cfdb-export&form=form+name&filter=Route%3abc
    i.e. Route=abc

    But actually shows
    http://example.com/wp-admin/admin-ajax.php?action=cfdb-export&form=form+name&filter=Route%3D%24_GET%28routex%29
    i.e. Route=$_GET(routex)
    It shows this b/c the short code is just making the shortcode parameters into URL parameters. It should dereference $_GET (and $_POST, $_COOKIE)

    Thread Starter andywt

    (@andywt)

    I downloaded and activated v2.9.16RC1. Doesn’t seem to populate the value.

    Here is my shortcode:
    [cfdb-export-link form="Flag Database" orderby="Route,Neighborhood" show="Submitted,First Name,Last Name,Phone,Route" filter="Route=$_GET(status)"]

    Here is the URL is used to call the shortcode:
    http://www.pros.org/flags/export-test/?Route=8/

    Here is the link that Export has:
    http://www.prosperrotary.org/flags/wp-admin/admin-ajax.php?action=cfdb-export&form=Flag+Database&orderby=Route%2CNeighborhood&show=Submitted%2CFirst+Name%2CLast+Name%2CPhone%2CRoute&filter=Route%3D

    Plugin Author Michael Simpson

    (@msimpson)

    filter="Route=$_GET(status)"
    means in the URL you would have to change to:
    http://www.pros.org/flags/export-test/?status=8/

    alternately change the filter:
    filter="Route=$_GET(Route)"

    Thread Starter andywt

    (@andywt)

    Sorry Michael,
    I used the wrong shortcode. When I fixed it it did work as expected! Thanks much

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘using a variable from url in shortcode’ is closed to new replies.