Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
I want to make it so that the emails that are sent via the members module will use text from a field on a hidden page I create. This way my client will be able to change the text that the emails say on their own. Is this possible to do?

Thanks! And as always, this script kicks butt!
Yes this is possible @BlueCaret. You could create an emails template with various textarea editable regions for the different emails. For instances where within the email you would output the value of a Couch variable, you could use shortcodes (docs/miscellaneous/shortcodes.html) to make such placeholders more obvious to the client.

Do let us know if you have any questions in regards to implementing this feature.
cheesypoof wrote: Yes this is possible @BlueCaret. You could create an emails template with various textarea editable regions for the different emails. For instances where within the email you would output the value of a Couch variable, you could use shortcodes (docs/miscellaneous/shortcodes.html) to make such placeholders more obvious to the client.

Do let us know if you have any questions in regards to implementing this feature.


Hi cheesypoof, thank you for the reply. I tried looking into this and tried it myself but just can't figure it out so ya if I could get some guidance that would be great.

The shortcode part I can get figured out but its getting a page's variables into the admin code that I have problems with.

To be specific I want to set the text that the members module uses when it sends emails to be changed by my client in the admin panel using a hidden page.

So it's getting that hidden page's fields to show in the config.php file of the members module that I need help with. Specifically this:

Code: Select all
    // registration
    $t['activation_email_subject'] = 'New Account Confirmation';
    $t['activation_email_msg_0'] = 'Please click the following link to activate your account:';
    $t['activation_email_msg_1'] = 'Thanks,';
    $t['activation_email_msg_2'] = 'Website Name';
The key point here to understand is that we disable the default emails sent by some of the members module tags. You can then instead send these emails with the send_mail tag, allowing full control over the content. We essentially ignore those translations you mentioned. Please see #4 under "Usage" in viewtopic.php?f=5&t=8063. Does that make sense?
Okay so I think I got this and I think it will work except for one snag...

I'm wanting to do this for the members module registration email. So I need to be able to include the activation link. Is it possible to get the activation link into a shortcode? And if so how would I do that?
Okay so I figured out how to get the activation link. FYI for others its just using:
<cms:show k_member_activation_link />

I still have an issue though. I decided to forego using shortcodes at the moment and am just hardcoding an email message in using couch's send_mail function inside the register.php file.

I have it working perfectly for when the user first signs up, but I also want an email to be sent out once the user has clicked the activation link. To do this I put a send_mail tag into register.php near the top where <cms:if success_msg >.

My problem is trying to get the user's email to be added into the "to" field for the email. For the email that gets sent when they first register I just did to=k_member_email but it seems this variable isn't available when the activation link is clicked. I did check using cms:dump to see if the variable is in there but I didn't see it there either.. I'm worried that this isn't going to work for me...

Any idea how to get the user's email in there?
Nevermind! Got it figured out! I had to pull the ID from the URL in order to get the right context for the user. Below is the code I used:

Code: Select all
<cms:set memberid = "<cms:gpc 'id' method='get' />" />
<cms:pages masterpage=k_member_template id=memberid>
    <cms:send_mail from=member_email to=member_email subject='Account Activated!'>
    ...
    </cms:send_mail>
</cms:pages>
The member variables should already be set directly after <cms:member_process_activation/>, if successful:
Code: Select all
<cms:set action="<cms:gpc method='get' var='act'/>"/>

<cms:if action='activate'>
    <cms:member_process_activation/>

    <cms:if k_success>
        <cms:send_mail from=k_email_from subject='Account Activated' to=k_member_email>
            Hello <cms:show k_member_title/>,

            Your account has been activated!
        </cms:send_mail>

        <cms:set_flash name='success_msg' value='2'/>
        <cms:redirect k_page_link/>
    <cms:else/>
        <cms:show k_error/>
    </cms:if>

<cms:else/>
    <!-- Registration form -->
</cms:if>
If you want to verify that this is the case, temporarily remove the redirect and place a <cms:dump/>.

The shortcodes could be implemented like so:
Code: Select all
<cms:send_mail from=k_email_from subject='Account Activated' to=k_member_email>
   <cms:do_shortcodes><cms:get_custom_field masterpage='emails.php' var='activated_email'/></cms:do_shortcodes>
</cms:send_mail>
In your addons/kfunctions.php, an example shortcode would be:
Code: Select all
$FUNCS->register_shortcode( 'member_title', 'member_title_handler' );
function member_title_handler( $params, $content=null ){
    global $CTX;

    return $CTX->get( 'k_member_title' );
}
In the admin panel textarea, you would then just type [member_title].
Ah awesome! That's a much better way! Thanks!
9 posts Page 1 of 1