latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

File download url in echo string

Home Forums Community Forum File download url in echo string

This topic contains 5 replies, has 3 voices. Last updated by  Raam Dev 4 years, 1 month ago.

Topic Author Topic
Posted: Thursday Nov 15th, 2012 at 4:16 am #31665

Hello, I’m not an php expert ;-)
Here is the code which I use to show the link of download to the members and the link of registration for the not members.
I added another parameter which is a condition if the file to be downloaded exists.

if (in_array('zipfull', get_field('fichiers_zip')) and current_user_can("access_s2member_level3"))
	echo '<a title="Right clic to download this file" href="#">Zip Full (Between 3M and 6M pixels)</a><br/>';
else if (in_array('zipfull', get_field('fichiers_zip')))
	echo '<a title="Right clic to download this file" href="/join">Zip Full (Between 3M and 6M pixels)</a><br/>';
else 						
	echo 'No file to download';

Now I have to replace the url of download # by the real url and the good name of zip file.
I obtains the name of the file to be downloaded by this code

<?php the_field('id_model')_full.zip;?>

I looked at this page but I do not understand how to organize the group.

Thank you for your help

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Thursday Nov 15th, 2012 at 8:58 am #31680

Hi Emmanuel.

I’m not sure I understand the_field(‘id_model’), is that your actual code? Where is your the_field function defined? Or did you mean get_field. If so, then the code should probably be:

[hilite pre_code]

[/hilite]
Posted: Thursday Nov 15th, 2012 at 9:49 am #31691

get_field or the_field are functions defined in my custom functions.

But my main problem si how can i integrate the URL of zip fil in my if-elseif-else condition.

echo '<a title="Right clic to download this file" href="#">Zip Full (.....

at the place of href

Posted: Thursday Nov 15th, 2012 at 3:30 pm #31720
Raam Dev
Username: Raam
Staff Member

I’m not sure how the the_field() function works, but you might try something like this:

echo '<a title="Right click to download this file" href="' . the_field('id_model') . '_full.zip">Zip Full (.....
Posted: Friday Nov 16th, 2012 at 5:21 am #31750

Sorry but don’t work.

I need to use the protected zip file. I must use a mix between
My Conditions if zip file exist and if member or no.

My function to make my zip file, like this id_model_full.zip, for example marilyn_full.zip, this file is in my protected folder.
I must use something like this

<?php
if (in_array('zipfull', get_field('fichiers_zip')) and current_user_can("access_s2member_level3"))
	echo '<a title="Right clic to download this file" href="s2member_file_download_url(array("file_download" => "' . the_field('id_model') . '_full.zip")">Zip Full</a><br/>';
else if (in_array('zipfull', get_field('fichiers_zip')))
	echo '<a title="Right clic to download this file" href="/join">Zip Full (Between 3M and 6M pixels</a><br/>';
else 						
	echo '';
?>

Of course my code is wrong :-)

Posted: Friday Nov 16th, 2012 at 7:02 pm #31840
Raam Dev
Username: Raam
Staff Member

Hi Emmanuel,

I’m not sure what’s wrong with the code but I recommend posting your question on wordpress.stackexchange.com or the WordPress.org Support Forums.

This specific question is outside the scope of s2Member support. If you have any questions about the s2Member Conditionals themselves, or any other part of s2Member, please let us know and we will gladly provide assistance.

Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.