Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Changing Unsubscribe url in Topic Notification Email
Avatar
Derek Ellerman
Member
Free Members
sp_UserOfflineSmall Offline
Mar 6, 2013 - 11:38 pm

Hi -

I'd like to change the unsubscribe url given by default at the bottom of notification emails.  The current default one isn't working for me as it doesn't properly insert their username into the url, triggering a redirect to another page.  Is there a filter I can add to my functions.php file to modify this url?  

The current line says: 'To unsubscribe, please visit your profile: http://everydayfeminism.com/fo.....scriptions'

Thanks!

Derek

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 7, 2013 - 4:00 am

It should work OK if they are still logged in to your site or still have an active cookie. If not then that login step is still going to be necessary. The normal SP profile URLs do not, in normal use, actually pass the user name or ID.

The nearest filter available would be 'sph_subscriptions_notification_email' which passes in 3 parameters. First is the email message text, next the post details array as a second parameter. The third parameter is the users ID.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Derek Ellerman
Member
Free Members
sp_UserOfflineSmall Offline
Mar 10, 2013 - 3:19 pm

Great - I'll give it a shot - thanks so much!

Derek

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 10, 2013 - 3:47 pm

Let us know how it goes...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Dave Hughes
Member
Free Members
sp_UserOfflineSmall Offline
Oct 15, 2013 - 12:12 am

The unsubscribe URL currently links to "...profile/?ptab=subscriptions&pmenu=topic-subscriptions". I would like to change this to "profile/?ptab=subscriptions&pmenu=forum-subscriptions" to make it easier for my members to unsubscribe from a forum since we are primarily using forum subscriptions not topic subscriptions. Is this possible?

 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 15, 2013 - 12:46 am

you would need to hook into the message prior to it being sent and do a php str_replace on the url with the updated on...

the filter to use would be:  sph_subscriptions_notification

do you know how wp filters work?

Avatar
Dave Hughes
Member
Free Members
sp_UserOfflineSmall Offline
Oct 15, 2013 - 1:18 am

No, I am not familiar with wp filters. Can you provide more specific instructions or refer to a tutorial on how to do this.

 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 15, 2013 - 10:55 am

here is wp codex entry:  http://codex.wordpress.org/Plugin_API

so something like:

add_filter('sph_subscriptions_notification', 'my_url_changer', 10, 2);
function my_url_changer($msg, $newpost) {
    $msg = str_replace('old_url', 'new_url', $msg);
    return $msg;
}

of course, untested and you have to put in the original url and new url...

Avatar
Dave Hughes
Member
Free Members
sp_UserOfflineSmall Offline
Oct 16, 2013 - 7:38 pm

I have studied the WP codex page you referenced. I think I understand the filter concept now and the code you suggested. The only thing I am not sure of is where exactly I should insert this code. Does it go into one of the existing php files, or do I need to create a child theme and put this into a new functions.php file?

I have been reading about child themes recently and I understand this is the best way to make modifications of WP code so changes are not lost during updates. This will be my first attempt at doing code modification so I really appreciate any extra assistance you can provide.

 

Avatar
Brandon
U.S.
SP Wrangler
Free Members
sp_UserOfflineSmall Offline
Oct 16, 2013 - 11:09 pm

If you are running a custom Simple:Press theme you can put it in the spFunctions.php file that is in the theme's /template folder.

 

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17363
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625