Support » Fixing WordPress » Print a URL passed variable on your WP Page?

  • I know I am so close and missing something simple here. I have passed a variable from one WordPress page to another using:

    The variable and value is available when I get to the new page but I don’t know how to simply print the variable value (333) on the page.

    Any suggestions would be appreciated.

Viewing 15 replies - 1 through 15 (of 18 total)
  • Could you post any code that you have so we can take a look?

    That’s the problem. I have accessed the URL variable through Gravity forms and the variable is {entry_url}SendTo
    that holds the value passed from one page to another. I am thinking I should be able to go to the page HTML Tab and simply add a type of Print variable code to get it to display on the page.
    Does that make sense? I’ve looked all over for various html code to print variables but nothing is working, the actual code shows on the page rather than the value of the variable.

    So if your trying to access the variable via Gravity Forms, you need to post there to get support. I have a developers account there and they are great about supporting these issues. This forum does not support premium plugins or themes since we cannot download the code without paying first to look at it.

    Thanks graphical. I am trying to print this variable above the Gravity Form, not within it. My first goal was to pull the variable into the Gravity form and display it. That worked but I could not set the Field to “Read Only” because Gravity forms doesn’t have that option. My next step was to show the field above the form in a Print type statement. I know it’s convoluted but it seemed to be a workable solution. I am not that great at HTML but I can get most simple code accomplished.
    I appreciate your comments.

    Ok, so really gravity forms has nothing to do with this. Fine. So you are saying that you want to get the value that is passed in a url? In your example http://www.page1/?Les=333 you want to get Less=333 and store it in a php variable correct? From there you should be able to do whatever you want with it.

    Yes, Les is the variable and 333 is the value of the variable. All I want to do is print 333 above the form in the content portion of the WP page.

    Obviously the value of “333” will change based on what page originated the call to this page.

    Thank you for your patience…

    You can use GET to get the variable passed in the url. So you need to grab Les=333 and put that in a variable. From there you can manipulate it by breaking it up into Less and 333. Whatever you want to do at that point.

    This should help you:

    Thanks Graphical.
    I entered both

    echo ‘Hello ‘ . htmlspecialchars($_GET[“SendTo”]) . ‘!’;

    (To show the variable)
     if($_GET["SendTo"] === "") echo "a is an empty string\n";
     if($_GET["SendTo"] === false) echo "a is false\n";
     if($_GET["SendTo"] === null) echo "a is null\n";
     if(isset($_GET["SendTo"])) echo "a is set\n";
     if(!empty($_GET["SendTo"])) echo "a is not empty";

    (and this to show a possible error)

    Go to this page:
    select anyone to send an email to and it will take you to the next page and at the bottom you will see the results of the entered code. It just prints it out rather than executing the code.

    Moderator Andrew Nevins


    Are you putting the PHP in the Visual/ Text editor?

    I understand what you want to do, I’m just confused on what you code looks like exactly. So you are using the code on the page you are landing on correct?

    So if I go to http://www.page1/?Les=333 then the page that I land on uses the code to then get the url.

    This is a php question rather than a WordPress question. You should be able to find out with a google search like this: get variable from url php

    Andrew, yes I am putting the code in the “Text” tab

    Graphical. When you choose a staff member on page one you are taken to page two, and a variable is passed through the URL telling page 2 what staff member you chose. It then auto populates the Gravity Form To Email variable so it knows where to send the form. If you look at the top of the form you will see the staff members name was populated correctly. The issue is, it’s not a read only field. If someone typed over the Members name the email would not be sent correctly. Once I figure out how to display the URL variable on this page, I will set the Gravity Form variable to “Private” so it can’t be seen and over written.

    Hope that clarifies…

    You can’t run php in the text tab. It has to be in the code of the page/page template. You may find a plugin that allows you to do that.

    Thanks Graphical, as I mentioned web code is not my strong point. Is this where a Short Code might work? I am an old coder from way back but I prefer WYSIWYG type wed design like Joomla or WordPress.
    COBOL was my first language…

    There may be a plugin to assist you with this but I don’t know of any. I DO know that you can do it in the code so that is what I can offer.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Print a URL passed variable on your WP Page?’ is closed to new replies.