Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

hook into s2member file download functions WordPress


I'm using s2member plugin to restrict downloads. it has several hooks that can be used to customize the functionality.
here are the hooks documentation :

this works :


function wpc_notify_file_download(){
wp_mail('[email protected]','test','test');
wp_redirect( '/thank-you/' ); exit;

but if I use the after download access hook, it doesn't work, the hook doesn't seem to fire.

also, if a non member tries to download, they are redirected to a register page, I'd like the download to start automatically once they register and log in.

Answers (1)


Christianto answers:

Hi Paul,

From what I see, the function uses exit() before the action running..
this might terminated the function, so ws_plugin__s2member_before_file_download_access won't work, [[LINK href=""]]this thread[[/LINK]] have the same issue with the hook.

paul de wouters comments:

the ws_plugin__s2member_before_file_download_access hook works, the ws_plugin__s2member_after_file_download_access doesn't.
and I'm the one who posted that question on the s2member forums :)

Christianto comments:

Ouch.. :D

Yes, ws_plugin__s2member_before_file_download_access will work because it fired before the script terminated with php exit(), and ws_plugin__s2member_after_file_download_access fired after exit() run.

You can check their position on s2member codex..