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.
Options

Change registration email text

ercatliercatli
edited January 2012 in Vanilla 2.0 - 2.8

I have enough familiarity with php to make changes to files (sometimes), but not enough understanding of Vanilla to find the things I want.

I want to change the text in emails and other messages around the site. I don't think there are plugins for this, and I don't think they're part of themes. Can someone tell me please specifically where to find the file which controls the registration email text, and (more generally) how to go about finding where different things like this are?

I'm aware of the dangers of changing files, I back up and I keep a note of files I've changed so I can continue the changes if I upgrade. And I'm happy living dangerously! : )

Best Answers

  • Options
    Answer ✓

    You can use the localization features of Vanilla. All text messages for the active locale (including mails) are stored in a large array. When the locale is loaded, this array is filled from multiple .php files (in the locale folder, in the plugin folders...) but also from 2 files : conf/locale.php and conf/locale-[locale name].php (ex : locale.en_CA.php).

    For a project specific change, I think the simpliest way to go is to add or modify the conf/locale.php and add entries for the messages you want to modify. This way when you do you next update, you will just have to keep this file in you new conf.

    To know the key of the message you want to change, look for the text of the in the source code (it is the first parameter of the call to the T() function). Be careful to use the placeholders for parameters exactly as they appear in the text.

    Some keys for mail messages are : 'EmailNotification', 'EmailPassword', 'EmailStoryNotification', 'EmailWelcome', 'EmailWelcomeConnect', 'EmailWelcomeRegister' but this technique works for any message in the application.

    The conf/locale.php to change the invitation would look like this :

    <?php if (!defined('APPLICATION')) exit();
    
    $Definition['EmailInvitation'] = 'Hi fellow,
    
    %1$s invited you to have fun with %2$s. To join, just click on this link :
    
      %3$s
    
    See ya,';
    ?>
    

    Warning : it looks like you may have to force a reload of the locale in the dashboard the first time you create this file

  • Options
    Answer ✓

    @ercatli

    Try to add in locale.php
    $Definition['[%s] Welcome Aboard!'] = '';

    You can check the SendWelcomeEmail() function in class.usermodel.php

Answers

  • Options
    Answer ✓

    You can use the localization features of Vanilla. All text messages for the active locale (including mails) are stored in a large array. When the locale is loaded, this array is filled from multiple .php files (in the locale folder, in the plugin folders...) but also from 2 files : conf/locale.php and conf/locale-[locale name].php (ex : locale.en_CA.php).

    For a project specific change, I think the simpliest way to go is to add or modify the conf/locale.php and add entries for the messages you want to modify. This way when you do you next update, you will just have to keep this file in you new conf.

    To know the key of the message you want to change, look for the text of the in the source code (it is the first parameter of the call to the T() function). Be careful to use the placeholders for parameters exactly as they appear in the text.

    Some keys for mail messages are : 'EmailNotification', 'EmailPassword', 'EmailStoryNotification', 'EmailWelcome', 'EmailWelcomeConnect', 'EmailWelcomeRegister' but this technique works for any message in the application.

    The conf/locale.php to change the invitation would look like this :

    <?php if (!defined('APPLICATION')) exit();
    
    $Definition['EmailInvitation'] = 'Hi fellow,
    
    %1$s invited you to have fun with %2$s. To join, just click on this link :
    
      %3$s
    
    See ya,';
    ?>
    

    Warning : it looks like you may have to force a reload of the locale in the dashboard the first time you create this file

  • Options
    ercatliercatli
    edited January 2012

    That is a tremendous help thanks. I had noticed a lot of ['Email']['xxxxx'] settings in the config-default.php file, but never would have thought to look in locale.php files - locale is not something I understand yet.

    But you have given me heaps of info - it just remains to be seen if I can get it right! Thanks again.

  • Options
    422422 Developer MVP
    edited January 2012

    Imagine vanilla as a house.

    A folder as a room

    A file as a piece of furniture.

    You can create a room, outside of the house with different furniture etc.
    Yet when you walk in the house you see the new room and stuff.

    Its magic.

    If you dont even see the house lol, your in trouble

    There was an error rendering this rich post.

  • Options

    Olivia_Chevet

    I've had a bit more of a look and that seems to be OK. I presume I find the text in the definitions.php file?

    Two questions please:

    1. Where is the title of the email stored?
    2. And is there any reason why I shouldn't change it in the definitions.php file? (I'm presuming it is because that would mean I'd have to re-edit the file every time I upgrade?)
  • Options

    @ercatli Right, bu putting your changes in locale.php you can keep them without a change every time you make an update. You also easily know which changes you have made, having them all in a single file.

    For some mails, here are the titles I have identified :

    $Definition['[%1$s] %2$s'] = '[%1$s] %2$s'; // EMail title
    $Definition['[%s] Invitation'] = '[%s] Invitation'; // Email title
    $Definition['[%1$s] Membership Approved'] = ;       // Email title
    $Definition['[%s] Confirm Your Email Address'] = ;     // Email title
    $Definition['[%s] Welcome Aboard!'] = ;               // Email title
    $Definition['[%s] Password Reset'] = ;          // Email title
    

    For email notifications of activities, the general structure of the email title is '[%1$s] %2$s' , which you should be able to change with a line like this one

    $Definition['[%1$s] %2$s'] = '%1$s - %2$s';
    

    The first parameter is your forum name.

    The second parameter is the activity headline, which is defined with keys having the structure 'Activity.XXXX.YYYY' where XXXX it the name of the activity and YYYY is either 'ProfileHeadline' or 'FullHeadline'.

    Some actvity identifiers are ActivityComment, AddedToConversation, BookmarkComment... You can check the content of the Name column of the gdn_activitytype table

    This means that the title of the email will always be the same as what appears in the notification view.

    $Definition['Activity.PictureChange.FullHeadline'] = '';

    Hope this helps.

  • Options

    Thanks again. You are pushing me beyond my knowledge and understanding, but I hope I can work it out from there.

    Just to explain why I have a problem. Vanilla uses the Banner Title (set in the Dashboard) in several ways - as text in the welcome email and as a title on each page and a link back to the forum home page.

    But my forum is incorporated into a larger website which has its own title and links. I have modified the theme (Embed Friendly) to include the standard website header on top of the Vanilla header, but that means I don't want to use the Banner Title as a title, but only as a link. So I have modified the banner title to simply read "Forum home" and styled it smaller to fit with the other links (Dashboard, Sign in, etc). This works fine, but it puts a strange title ("Forum Home") in the welcome email title and text. So I just need to change both title and text. I can do the text I think, so it was just the title. I'll let you know if I succeed, but I may be out of action for a week so don't hold your breath!

    Thanks heaps.

  • Options

    @ercatli You may try this int the conf/locale.php

    $Definition['[%1$s] %2$s'] = 'My forum - %2$s';
    $Definition['[%s] Confirm Your Email Address'] = 'My forum - Confirm Your Email Address';
    

    and other titles you want to change (see my previous post)

    %1$s is replaced by your community name in this context. Is you want something different, simply replace it.

  • Options

    Olivier,

    I have been away on holidays, so didn't get back to you earlier. But I can most of it to work (i.e. any changes I want to make in the text), but not the email title.

    I found I had to modify two files as follows:

    conf/locale.php - which now has this code (this is the whole file):

     <?php if (!defined('APPLICATION')) exit();
    
     $Definition['[%1$s] %2$s'] = 'SiteName - %2$s';
    
     $Definition['EmailWelcomeRegister'] = 'You have successfully registered for an account at  SiteName. Here is your information:
    
        Username: {User.Name}
        Email: {User.Email}
    
      You can access the site at {/,exurl,domain}.';
     ?>
    

    applications/dashboard/locale/en-CA/definitions.php - where I slightly modified the signature on the bottom of the email (successfully).

    Unfortunately, the welcome email still has the Banner Title in its subject rather than the SiteName. Do you have any other thoughts please? I can't find anywhere else where I can make a change, but I am not very familiar with Vanilla 2.

    Thanks.

  • Options
    Answer ✓

    @ercatli

    Try to add in locale.php
    $Definition['[%s] Welcome Aboard!'] = '';

    You can check the SendWelcomeEmail() function in class.usermodel.php

  • Options

    Thanks Olivier. That didn't work, but it put me on the path. I simply amended your extra code as follows:

        $Definition['[%s] Welcome Aboard!'] = '[SiteName] Welcome!';
    

    And that worked. Of course it doesn't fix other emails, but I can worry about that later.

    Thanks for all your help.

  • Options

    I just edited mine. I think the locale info has moved to applications/dashboard/locale/en-CA/definitions.php At least in my version of the site which is fairly new. FYI

  • Options
    peregrineperegrine MVP
    edited October 2012

    there are a number of places definitions can be read.

    you can put in your theme, plugins or conf/locale.php. All will work. Although if you have multiples of the same definition, you would need to test which one is read last.

    if you put it in conf/locale.php

    just be aware that installing vanilla 2.0.18.4 will replace it. Not sure if they fixed that in vanilla 2.1

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

Sign In or Register to comment.