Page 1 of 1

retrieving file request from URL with $_GET

PostPosted: December 26th, 2011, 11:29 pm
by stonecoldcnc
I'm trying to use the requested file name from the URL in another pluging. The code below works fine if I drop it into a new page BUT it does not work if I use it in another plugin. The variable $file_download_req is always = "!!! no filename !!!".


Code: Select all
<?php
$_g = stripslashes_deep ($_GET);

   if (isset ($_g["_s2member_seeking"]["file"])) {
   
   $file_download_req = esc_html ($_g["_s2member_seeking"]["file"]);
   
   } else {
   
   $file_download_req = '  !!!  no filename !!!  ';
   }
   echo 'file= ' . $file_download_req;
?>


The URL to retrieve the filename from looks like that (...?_s2member_seeking[type]=file&_s2member_seeking[file]=TestFile-CRRR540.dxf....)

All I need is to get the filename TestFile-CRRR540.dxf from the URL for further use in the other plugin.

Any help or hint would be greatly appreciated.

Re: retrieving file request from URL with $_GET

PostPosted: December 27th, 2011, 6:17 am
by Cristián Lávaque
So you're trying to use the Membership Options Page variables in another WordPress installation? Are the variables in the URL for the page where you're trying to use them?

What is the URL of your s2Member installation and what is the URL of the page where you're trying to use this variable?

Thanks!

Re: retrieving file request from URL with $_GET

PostPosted: December 27th, 2011, 7:54 am
by stonecoldcnc
Hi Cristián
perhaps I wasn't clear enough, I do not want to use the s2member variables in another Wordpress installation, I want to use them in a plugin which is installed in my Wordpress installation.

The URL to retrieve the filename from looks like that:
http://stonecoldcnc.com?s2member_file_download=Abey-CR540.dxf

As I said before, the code I've posted above your post is working fine if copied into a post/page but not in another php file which is a simple welcome email plugin. I just need to get the filename from the URL so I can send it with the welcome email.

Re: retrieving file request from URL with $_GET

PostPosted: December 28th, 2011, 5:58 am
by Cristián Lávaque
How are you passing the URL to that PHP file? If you have it in a string, you could replace all the first part with nothing.

Code: Select all
$filename= str_replace('http://stonecoldcnc.com?s2member_file_download=', '', $url); 


I hope that helps.