PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

notify by email when file downloaded

s2Member Plugin. A Membership plugin for WordPress®.

notify by email when file downloaded

Postby sidera » June 11th, 2011, 3:44 pm

Hi

is there a way to send an email to the admin whenver a file is downloaded?

thanks
User avatar
sidera
Registered User
Registered User
 
Posts: 21
Joined: March 4, 2011

Re: notify by email when file downloaded

Postby Cristián Lávaque » June 12th, 2011, 12:02 am

s2Member doesn't do that, but you could look in the source files and find a hook to use with a custom code that'd email you everytime a download happens.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: notify by email when file downloaded

Postby sidera » June 15th, 2011, 4:22 am

ok, can you point me to the file? thanks
User avatar
sidera
Registered User
Registered User
 
Posts: 21
Joined: March 4, 2011

Re: notify by email when file downloaded

Postby Cristián Lávaque » June 15th, 2011, 7:17 pm

Browse these, you'll probably find one that you can use for your customization viewtopic.php?f=40&t=9134&src_doc_v=110605 :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: notify by email when file downloaded

Postby Cristián Lávaque » June 15th, 2011, 7:25 pm

Another idea would be to have the custom script that sends you the email be what the person clicks on and then forward him to the actual download.

1. Person clicks on link to your custom script.
2. Custom script sends you an email.
3. Custom script forwards person to the file.
4. s2Member serves the file.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: notify by email when file downloaded

Postby sidera » June 16th, 2011, 9:32 am

I managed to get an email sent with the ws_plugin__s2member_before_file_download_access hook, but not the ws_plugin__s2member_after_file_download_access

what if I want to redirect the user after the download to a thank you page, so Ican track the goal in google analytics?
User avatar
sidera
Registered User
Registered User
 
Posts: 21
Joined: March 4, 2011

Re: notify by email when file downloaded

Postby Cristián Lávaque » June 16th, 2011, 11:08 am

Hmm... I don't know how to do the redirection after download. :|
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: notify by email when file downloaded

Postby sidera » June 16th, 2011, 4:23 pm

wherer can I get help with this kind of customization?
User avatar
sidera
Registered User
Registered User
 
Posts: 21
Joined: March 4, 2011

Re: notify by email when file downloaded

Postby Cristián Lávaque » June 16th, 2011, 5:12 pm

jobs.wordpress.net, oDesk, eLance, ScriptLance.

By the way, you may be able to use the ws_plugin__s2member_after_file_download_access hook for the redirection to the thank-you page you mentioned. viewtopic.php?f=40&t=9572&src_doc_v=110605#src_doc_line_238

I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: notify by email when file downloaded

Postby sidera » June 16th, 2011, 6:26 pm

yeah I tried using this hook because I believe it's the right one, however it's not being triggered??
User avatar
sidera
Registered User
Registered User
 
Posts: 21
Joined: March 4, 2011

Re: notify by email when file downloaded

Postby Jason Caldwell » June 17th, 2011, 5:25 pm

Thanks for the heads up Cristián.

Yea, this Hook is misleading, it's not the right one to use in this case. Sorry for any confusion in the name of this Hook, but this Hook is really only fired in special cases, which may occur whenever a download attempt is being re-routed in some way; not useful in this case though.

In fact, I wouldn't Hook into the s2Member download routine at all ( at least, not to perform a redirection ), because it could interfere with a successful delivery of the file itself. Instead, you might consider spawning a new window, or doing something else creative with the link itself. For instance, with Google Analytics, I recommend one of these methods:

Reference articles:
http://www.google.com/support/analytics ... swer=55529
http://www.google.com/support/googleana ... swer=55527
http://www.goodwebpractices.com/roi/tra ... cally.html

All of this being said, we are planning to create an API Notification for File Downloads, which will make new things possible, such as automatic email notifications and custom scripts that can receive the event as well. Look for this come to come in a future release. Until then, if you'd like to add this type of funcntionality yourself, you might try this Hook: ws_plugin__s2member_during_file_download_access

Also see documentation:
viewtopic.php?f=40&t=9134&src_doc_v=110605#src_doc_ws_plugin__s2member_during_file_download_access
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: notify by email when file downloaded

Postby Cristián Lávaque » June 17th, 2011, 11:28 pm

Awesome! I learnt a few new things with those articles on Google Analytics. Thanks. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: notify by email when file downloaded

Postby sidera » June 18th, 2011, 4:39 am

thanks Jason,

I'll use one of those methods instead of the redirect.
the mail notification works with the hook you mentioned.

I have another question : what data is available during that event, to send in the email, like member name, file name, etc...?

thanks!
User avatar
sidera
Registered User
Registered User
 
Posts: 21
Joined: March 4, 2011

Re: notify by email when file downloaded

Postby Jason Caldwell » June 20th, 2011, 3:36 am

You're very welcome.

There are many variables available with this Hook. As seen in the source code, you get all PHP variables defined within the scope of the Hook, at the precise point in which the Hook is fired by s2Member. Looking at the source code is probably the easiest way: viewtopic.php?f=40&t=9572&src_doc_v=110605#src_doc_line_175

Note how s2Member passes you the value of get_defined_vars(), as explained here in the Hook example: viewforum.php?f=40#src_doc_overview_description

Here is a quick example with some of the most useful variables:
Code: Select all
<?php
add_action
("ws_plugin__s2member_during_file_download_access", "my_function");
function my_function($vars = array()){
    $user_id = $vars["user_id"];
    $file = $_GET["s2member_file_download"];
    $user = new WP_User($user_id);
    //print_r($user);
}
?>
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: notify by email when file downloaded

Postby sidera » June 20th, 2011, 2:27 pm

ok, so I did a print_r, and it seems all the variables I need are there, but I'm not sure how to use them, this gives me nothing :
Code: Select all
$first_name = $vars["user->first_name"];
   $last_name = $vars["user->last_name"];


this is part of the var dump
Code: Select all
[user] => WP_User Object ( [data] => stdClass Object ( [ID] => 1 [user_login] => paul [user_pass] => secrett. [user_nicename] => paul [user_email] => secret [user_url] => [user_registered] => 2011-06-02 19:05:22 [user_activation_key] => [user_status] => 0 [display_name] => paul [first_name] => [last_name] => [nickname
User avatar
sidera
Registered User
Registered User
 
Posts: 21
Joined: March 4, 2011

Re: notify by email when file downloaded

Postby Cristián Lávaque » June 20th, 2011, 10:20 pm

First and Last names seem to be empty in that array. Could you try $user->user_login?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: notify by email when file downloaded

Postby sidera » June 21st, 2011, 2:58 pm

fixed it :

Code: Select all
$user_info = $vars['user'];
$user_display_name = $user_info->display_name;
User avatar
sidera
Registered User
Registered User
 
Posts: 21
Joined: March 4, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 0 guests

cron