Title: using a variable from url in shortcode
Last modified: August 31, 2016

---

# using a variable from url in shortcode

 *  Resolved [andywt](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/)
 * 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/](https://wordpress.org/plugins/contact-form-7-to-database-extension/)

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

 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967136)
 * See [Filter Variable Substitution](http://cfdbplugin.com/?page_id=116)
 *  Thread Starter [andywt](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967215)
 * 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](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](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967260)
 * `filter="Route=$_GET(routex)"`
 *  Thread Starter [andywt](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967261)
 * duh. Thanks that did the trick!!
 *  Thread Starter [andywt](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967337)
 * is this implemented with the cfdb-export-link function?
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967353)
 * 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](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967456)
 * 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](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967477)
 * Short answer: I created a fix. Would you test the [development version](https://downloads.wordpress.org/plugin/contact-form-7-to-database-extension.zip)
   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&amp](http://example.com/?p=1&amp);**
   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&amp](http://example.com/wp-admin/admin-ajax.php?action=cfdb-export&form=form+name&amp);**
   filter=Route%3abc** i.e. `Route=abc`
 * But actually shows
    [http://example.com/wp-admin/admin-ajax.php?action=cfdb-export&form=form+name&amp](http://example.com/wp-admin/admin-ajax.php?action=cfdb-export&form=form+name&amp);**
   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](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967478)
 * 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](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967480)
 * `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](https://wordpress.org/support/users/andywt/)
 * (@andywt)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967482)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-to-database-extension_ffffff.
   svg)
 * [Contact Form DB](https://wordpress.org/plugins/contact-form-7-to-database-extension/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-to-database-extension/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/reviews/)

## Tags

 * [contact-form](https://wordpress.org/support/topic-tag/contact-form/)

 * 11 replies
 * 2 participants
 * Last reply from: [andywt](https://wordpress.org/support/users/andywt/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/using-a-variable-from-url-in-shortcode/#post-6967482)
 * Status: resolved