Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Notification Link in Email

The subdirectory for my forum is /forum, but I have my Wordpress Integration set to /community. When people get notified of activity, they get an email but it has the /forum/activity instead of the /community/#/activity for the embedded forum.

Is there a way to modify the link in the notification to have /community/# instead of /forum/ ?


  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Your /forum is the same exact forum even if you embed it because that is where the files reside. You can't change that because /community is not where you installed the forum it is only the link to the forum you embedded inside WP.

  • Let's say I change my folder name to /community, would that affect my embed negatively?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    no , but the link to the forum in the embed page must not be

    for example:

    I have my forum embedded in WP page and have link to that embedded forum page on the menu of the WP site. It should not be the url of the stand alone forum or you will have a feedback loop. Call that link The_Community , or Communities, not community , the same if it was called forum.

  • @vrijvlinder, coming back to this. I see that %2$s generates the links in notification emails. Is there a way to manually modify %2$s so that /forum/ is replaced by /community/ when those links are generated?

  • peregrineperegrine MVP
    edited August 2015

    you realize the %2 just refers to the second parameter in the sprintf function which is the portion of the Url

    • the Url is just the route(path) column in the activity table

    • which is acted upon by ExternalUrl function.

    just some ideas - you might try fooling with

    this can be modified with ExternalUrlFormat

    $Configuration['Garden']['ExternalUrlFormat'] = "";

    or perhaps

    $Configuration['Garden']['Webroot'] = '';

    or you can always modify Email object if needed.... beforesendnotification trigger

    you can look here as well

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • This looks like a ton of useful resources, @peregrine. Thanks so much! This should get me started on finding a solution.

  • So, your first option basically just worked out of the gate... I had to change it up a little bit since I'm embedded to:

    $Configuration['Garden']['ExternalUrlFormat'] = "";

    But, otherwise, working perfectly.


  • Welp, ran into the same issue as @jamesinc here:

    New discussions still have the /forum/.

    A further wrinkle: when clicking on notifications in the actual forum, the modified links with /community/ open in a new window while the /forum/ links (new discussions) just open in the same frame (as they should).

  • peregrineperegrine MVP
    edited August 2015

    3 options and a server rule config.

    1) don't embed your forum. there will always be something that is funky. (no matter what anyone else suggests some js or something won't work as expected).

    2) get @rbrahmson to code you up a plugin, pronto.

    or you might want to sharpen up your coding chops and write a plugin to modify the body in the Email object based on this event.... (you might want to file an issue on github as well).


    then the notification won't be changed and only the email will be changed.

    3) force target blanks to be removed.

    4) can't you use server rules to force the urls that are going to forum to be the embedded forum.

    5) leave out %2s period and just post a generic link back to your site in the message itself hard-coded.

    $Defintion['EmailStoryNotification'] ='%1\$s\n\nGo to the site for all your earthly delights';

    I'd go with rbrahmson or option 1 :eh:

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • So, for now (until I can sharpen my coding chops and can write a plugin), I think I've resolved to give up, just put a generic "visit /community to see!" in notifications; then they can use their User Box notifications to navigate directly to the update. That seems to solve pretty much all the issues. Not as integrated / slick as I'd like (a direct link to the update would be best), but doesn't have any funky side-effects (I was also having issues with mobile redirects not working... gah).

    Thanks for all your help / advice, @peregrine! Very much appreciated!

  • jamesincjamesinc Sydney ✭✭

    Seeing as you tagged me, maybe I'll throw my two cents in. You can mitigate the issue a little bit by adding some .htaccess rules to 301 redirect the /forum/* links to /community/#/* (or whatever... you get the idea)

    That way even if the links appear incorrectly at least clicking them will take you somewhere useful.

  • @jamesinc Did you do this? Have an example?

    When I try a 301 redirect from /forum/ to /community/ my embed fails to load.

  • if you want to change the url in the body in the e-mail

    you could put this in a plugin.

    this will work for any mail coming out of an activity.

    not sure how new discussions trigger mail.

    probably a better way to hook into phpmailer.

    but I believe this works...

    public function ActivityModel_BeforeSendNotification_Handler($Sender) {
    $Email = & $Sender->EventArguments['Email'];
    $Body = $Email->PhpMailer->Body;
    // change /vanilla/  to /strawberry/
    $Body = str_replace("/vanilla/", "/strawberry/", $Body);
    $Email->PhpMailer->Body = $Body;

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks for putting this up, @peregrine! I'll try this out this weekend!

Sign In or Register to comment.