WordPress.org

Ready to get started?Download WordPress

Forums

plugin to pass variables from external URL using $_GET (4 posts)

  1. chemoul
    Member
    Posted 7 years ago #

    Hi,
    I would like to be able to use a URL to grab variables from an external link and to then insert these variables into a link in the post that the external link is linking to.
    Say the external link on another website is: http://www.myblog.com/a-test-post.php?m=test&aa=test2

    I would then have some code in the plugin, like

    if(isset($_GET['link'])){
    	$m=$_GET['link'];
    }
    if(isset($_GET['aa'])){
    	$aa=$_GET['aa'];
    }
    $link="http://www.gohere.com/index.php?m=$m&aa=$aa";

    What I would like to do is then be able to insert link in my post, using some sort of tag, e.g. {mylink}

    How would I write such a plugin?

    Thanks.
    Steve

  2. alakhnor
    Member
    Posted 7 years ago #

    I'm not sure I understand.
    $_GET will check the url of your blog not an external url.
    If you know the external url, then just parse it and create your own link.
    Now, if you want to grab the url whence the call is, you need to use $_SERVER["HTTP_REFERER"] (and then parse it^^).

  3. chemoul
    Member
    Posted 7 years ago #

    well, referrer could be any referal url, not just from one specific domain.
    I've got another domain where links point to my blog. So the link on that other domain would be something like http://www.myblog.com/a-test-post.php?m=test&aa=test2
    I want to be able to parse the variables in this url to the php code described above, which is located in a plugin and then insert these variables in a different link that's in my blog post.

  4. pizdin_dim
    Member
    Posted 7 years ago #

    Start with the PHP parse_url() function.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.