cforms II User Forum

Registration is currently disabled.
Guest

FAQs

Login form protected by Login LockDown.


Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Accessing the tracking id from my-functions.php action() function
August 18, 2009
10:21 am
Guest

Please replace the ??? with your data!

 


Thank you for this tremendous plug-in you are very generous to spend so much time in developing and maintaining it.

If at all possible I would like to be able to access the tracking ID (the 'sub_id' value from the table 'cformsdata') from the actions() function in my-functions.php to build a link to an uploaded file.  I have searched extensively through the forums in order to find a solution but have been unable to attain the desired outcome.

I understand that I can access the tracking ID by using the 'get_cforms_entries' API call as stated in the forums here and here and have done so successfully.

I understand that I am supposed to be able to access the tracking ID as a predefined variable as stated in the help documentation.  I believe, although I need to test again, that the substitution happens correctly if using the '{ID}' placeholder in the admin email but I would like to access it from my-functions.php

This particular situation requires me to be able to access the filename from the submitted form data but as you well know I also need the tracking ID (noid) to correctly form the file link.  I have tried adding {ID} as the default value to a hidden field but no substitution occurs and I am left with the string '{ID}' as the submitted value.

I could query the database directly from the actions() function but I would need a unique identifier to extract a single record.  If at all possible I would like to use the one that already exists.

Is it possible to access the tracking id from the actions() function in my-functions.php so as to correctly form the link to the file?

If so how can I go about doing so?

Many Thanks,

Spence

August 18, 2009
6:25 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

drakemolatov said:

If at all possible I would like to be able to access the tracking ID (the 'sub_id' value from the table 'cformsdata') from the actions() function in my-functions.php to build a link to an uploaded file. 

try adding a global $subID; to your action function.

This particular situation requires me to be able to access the filename from the submitted form data but as you well know I also need the tracking ID (noid) to correctly form the file link.  I have tried adding {ID} as the default value to a hidden field but no substitution occurs and I am left with the string '{ID}' as the submitted value.

ps: cforms v11 will come with an option to turn off the file-upload-name-tracking-prefix. which of course bears the risk that files can be overwritten if they have the same name, but if that's a non issue for you, it could make things a lot easier.

August 19, 2009
2:49 am
Guest

Oliver said:

try adding a global $subID; to your action function.

Thanks Oliver this solution works perfectly.  Ideally the 'sub_id' would be available without using globals but for this applicaiton it is adequate.

ps: cforms v11 will come with an option to turn off the file-upload-name-tracking-prefix. which of course bears the risk that files can be overwritten if they have the same name, but if that's a non issue for you, it could make things a lot easier.

I like the fact that each uploaded file is assigned a unique identifier as it prevents collisions.  I just needed a way to access the id.

Thanks again for all your hard work.  You have made a wonderful tool for people.

May 20, 2012
5:59 pm
cande
Guest

Buy adding the 'global $subID' in a local context, it sets the local $subID to the global value.

 

I just learned some php :-)

May 27, 2012
2:59 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

well done :-)

August 30, 2012
6:18 am
Jason K
Guest

Oliver,

The global is nice but why not add the subid as an array element in $cformsdata array that is passed to the 

function my_cforms_action   as well.  Seem like it would be a easy and beneficial add on since you are pulling from the database to make the array already, which means you know the subid.

Just my 2cents.

Great plugin.

Forum Timezone: Europe/Berlin

Most Users Ever Online: 959

Currently Online:
37 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

tracedef: 43

mores: 21

Gyrus: 20

frozenwaste: 18

asuffredini: 15

photoworks: 14

Member Stats:

Guest Posters: 3732

Members: 1463

Moderators: 3

Admins: 2

Forum Stats:

Groups: 1

Forums: 4

Topics: 5333

Posts: 18693

Newest Members: juredujmovic, dreamkeeper, rajattyagi, wrokaa, lukass

Moderators: Paul (421), cnymike (8), sonika (95)

Administrators: Oliver (6400), Nicky (3)