URL Params

The URL Params WordPress Plugin allows you to access URL parameters in the Query String of the URL.

The plugin even allows you to specify a default value in the shortcode if the parameter isn’t set, so if you want to say “Hello, FirstName” and FirstName isn’t set, it could say something like “Hello, Friend!”

To specify a backup url paramater, enter multiple paramaters seperated by commas. The plugin will check for each paramter, in order, until a matching one is found and return that. Failing finding any of the paramaters you listed, the default will be returned. For example, you can specify [urlparam param="FirstName, First, name" default="Friend" /] to check for FirstName, and if not found, then First, if not found, then name, and if not, then just return “Friend”.

This is great if you have personalized links, like from Infusionsoft, as it lets you personalize a landing page with a persons name.

You can also use this to pre-fill out form fields for folks based on the querystring. For example, if their first name is passed in the URL, your landing page can greet the viewer by name and pre-fill their name on a form.

Installation:

To install the plugin, download the zip file and upload via the plugin interface of your WordPress site.

Usage:

Use the shortcode urlparam with the optional parameter of “default”. For example or [urlparam param="FirstName" default="Friend"/].

Updates:

  • 0.3: Released 6/25/2011. Added support for alternative paramters, i.e. param=”FirstName, First, name”

I’m always open to suggestions and ideas on how to improve this plugin. Please make suggestions by commenting below.

17 thoughts on “URL Params”

  1. Hi Jeremy,
    I’m trying to pass parameters via URL for the purpose of showing a different tracking phone number depending on the URL parameter passed, and in my efforts I found your plugin. The problem is that once the user clicks to a different page, the parameter is no longer there. The solution I think is to use some global variable or session data, but my PHP skills aren’t that great so I’m just trying to hack it all together. Is there a way to store a url parameter to a session variable and the call that data later after the user has clicked to a different page?

    Not to dilute from your plugin, obviously if there is way to do this with it that would be great, but my approach prior to finding your plugin was to use this code:
    (wordpress will probably filter some of this syntax)

    $val = $_GET[‘trackingphonenumber’];
    if(empty($val)) echo “Call us at 555-1212”;
    else
    echo “Call us at $val”;

    But I’m not storing that data to a session or calling it back.
    Any suggestions as to how I can mod your Plugin or my own code to make this work between pages?

    1. Great question! For starters, to do what your code does, you’d just use this:

      Call us at [urlparam param="trackingphonenumber" default="555-1212" /](

      To keep it between sessions and not get too complicated with plugins or PHP, just use Javascript. Have the JS check for the paramater. If it’s there, set a cookie. On subsequent page loads, have it check, if the cookie is set, have it modify the spot for the phone number on the page.

      Are you looking to embed this phone number in your site’s theme, i.e. on all pages? In that case, you can just hard code it with PHP in your child theme using PHP Sessions. (more info at http://www.php.net/manual/en/book.session.php )

  2. GoToWebinar Registration

    Thank you for creating this. I’m not sure how else to contact you, but is it possible to get more information about how to implement the plugin?

    Thanks
    Fred

  3. Dear Jeremy!
    I have some problems using your plugin tag within another tags.
    I.e. standalone [urlparam param="email" /] is working but if I’m including [urlparam param="email" /] into Shortcode Exec PHP tags like [subscribe][urlparam param="email" /][/subscribe] – the page generated contains a tag but not its value. So the “subscribe” script will receive [urlparam param="email" /] but not its value 🙁

    1. In order for a shortcode to be inside of another shortcode, the outside shortcode needs to run do_shortcode() on the return value. Most shortcodes don’t do this so that won’t work. If you want, go edit the code for your subscribe tag and set it up to return do_shortcode() on the return value. 🙂

    1. Sounds like there might be an issue with another plugin you have installed. Try disabling other plugins until you find the culprit! 🙂

  4. Hi Jeremy, I love what this plugin does.

    Question: how specifically do I set this up to have it work with a form.
    I use infusionsoft. I already setup the link to pass the customer information.

    On your examples above it specifies how to set it up as a “hello “john”” for example, but I am not sure how to set it up as to when the client arrives in the site, the form is pre-filled.

    Thanks in advance for your response.

    Jim.

  5. Jeremy, i’m using your great plugin on a few sites. I tried recently to deploy to a multisite installation and there seems to be some incompatibility with the Domain Mapping plugin. Are you aware of any other users communicating any difficulties when using URL Params with Multisite?

    1. There shouldn’t be any conflict with Multisite, Joe. It’s most likely another plugin botching up the reading of the params. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *