Home › Forums › Plugin Support › Customise emails and notifications
- This topic has 11 replies, 4 voices, and was last updated 12 years, 9 months ago by Khaled.
-
AuthorPosts
-
January 20, 2012 at 2:05 pm #247January 20, 2012 at 2:21 pm #248KhaledMember
You can use user_register action in your function.php file.
add_action( ‘user_register’, ‘yourUserRegisterFunction’);
function yourUserRegisterFunction( $user_id ){
// your code here
// you can use wp_mail function for sent mail
}Thanks.
January 21, 2012 at 4:51 pm #257EndcliffeMemberThanks for your reply. I’m not a WordPress developer so coding an action as you suggest is not easy for me.
I searched for a plug-in that might do what I want and I found “SB Welcome Email Editor” which is perfect – it allows me to customise the new subscriber email and also send a message to the administrator to notify new subscribers. However, it doesn’t seem to work with your plug-in, and in fact now that I have both your plug-in and this “SB Welcome Email Editor” a new user no longer receives the default email that was working prior to installing the latter plug-in.
Can you tell me if there’s a way to make this “SB Welcome Email Editor” and your plug-in compatible, or alternatively suggest another way (perhaps another existing plug-in) that will enable me to (a) customise the new user registration email and (b) setup an administrator alert email?
It seems that as a future enhancement to your plugin it might be better to integrate this functionality, in which case you could add an easy way for the values of the custom user fields to appear in the email messages.
Thanks
January 21, 2012 at 6:31 pm #259KhaledMemberOkay, let me write a script for you.
January 21, 2012 at 7:28 pm #261KhaledMemberPlease follow those instruction
1. Download and unzip following zip file:
http://wordpress-extend.com/wp-content/uploads/2012/01/emailController.zip2. This file contain umSetEmailController.php script, Upload umSetEmailController.php to wp-content/plugins/user-meta/controllers directory.
3. There will be new menu under User Meta in admin panel.
4. Update your setting.Please let me know, if this script is working for you.
January 24, 2012 at 9:14 am #279EndcliffeMemberHi,
You kindly provided me with some code to help manage emails with user-meta (username: Endcliffe). I have been trying to reply to you but there’s a problem with the support forums on your site:
“Sorry, we can’t find the content you’re looking for at this URL. Please try selecting a menu item from above or to the side of this message to get where you’d like to go. ”
Thanks very much for your help – the extra code does almost everything that I need. I am tweaking it to deal with my specific additional requirements but just have one more quick question – can you tell me how to extract a custom meta field so that I can do a substitution in the emails? For example, I have a custom field with meta name “instrument” and I want to substitute occurrences of %INSTRUMENT% in the email text with the value of this meta field. Could you give me a code snippet that will extract the appropriate value from the database?
Thanks again for your help – you have been very helpful. If there’s anything I can do to support your development (eg. Testimonial) then please let me know.
January 26, 2012 at 3:52 pm #286KhaledMemberAs per your above request, We will provide a modified script asap.
If you want to support us(Testimonial), it will be highly appreciable for us.
Thanks for your kind support.
January 28, 2012 at 11:19 pm #382adminKeymaster$data = str_replace( ‘%INSTRUMENT%’, @$user->instrument, $data );
Add this line, before line number 131 (before return $data)
Thanks.
March 6, 2012 at 11:06 am #847crash2040MemberHi, I’m trying to implement this changes in a registration form.
I made the changes in the filterContent function in the umSetEmailController to include some custom fields in the email.
But when I debug the code, the data came empty.
This is what i’m doing:
$data = str_replace( ‘%TITLE%’, @$user->title, $data);
$data = str_replace( ‘%PHONE_NUMBER%’, @$user->phone_number, $data);
$data = str_replace( ‘%FAX_NUMBER%’, @$user->fax_number, $data);
$data = str_replace( ‘%JOB_TITLE%’, @$user->job_title, $data);
$data = str_replace( ‘%EMPLOYMENT_SECTOR%’, @$user->employment_sector, $data);
$data = str_replace( ‘%ORGANIZATION%’, @$user->organization, $data);
$data = str_replace( ‘%COUNTRY%’, @$user->country, $data);
$data = str_replace( ‘%ADDRESS%’, @$user->address, $data);
$data = str_replace( ‘%ADDRESS_2%’, @$user->address_2, $data);
$data = str_replace( ‘%ADDRESS_3%’, @$user->address_3, $data);
$data = str_replace( ‘%CITY%’, @$user->city, $data);
$data = str_replace( ‘%STATE%’, @$user->state, $data);
$data = str_replace( ‘%ZIP_CODE%’, @$user->zip_code, $data);
$data = str_replace( ‘%NEWSLETTER%’, @$user->newsletter, $data);Is something wrong in the way I’m doing the change?
Thank you
March 6, 2012 at 5:29 pm #852KhaledMember$data variable should be return at the end of filterContent function, like:
…
$data = str_replace( ‘%ZIP_CODE%’, @$user->zip_code, $data);
$data = str_replace( ‘%NEWSLETTER%’, @$user->newsletter, $data);
return $data;is it there?
Thanks.
March 7, 2012 at 12:24 am #853crash2040MemberHi, Thank you for your reply.
This is the complete function I have:
function filterContent( $user, $data ){
$data = str_replace( ‘%BLOG_TITLE%’, get_bloginfo(‘name’), $data);
$data = str_replace( ‘%BLOG_URL%’, site_url(), $data);
$data = str_replace( ‘%USER_LOGIN%’, @$user->user_login, $data);
$data = str_replace( ‘%USER_EMAIL%’, @$user->user_email, $data);
$data = str_replace( ‘%DISPLAY_NAME%’, @$user->display_name, $data);
$data = str_replace( ‘%FIRST_NAME%’, @$user->first_name, $data);
$data = str_replace( ‘%LAST_NAME%’, @$user->last_name, $data);
$data = str_replace( ‘%USERNAME%’, @$user->username, $data);
$data = str_replace( ‘%PASSWORD%’, @$user->password, $data);
$data = str_replace( ‘%TITLE%’, @$user->title, $data);
$data = str_replace( ‘%PHONE_NUMBER%’, @$user->phone_number, $data);
$data = str_replace( ‘%FAX_NUMBER%’, @$user->fax_number, $data);
$data = str_replace( ‘%JOB_TITLE%’, @$user->job_title, $data);
$data = str_replace( ‘%EMPLOYMENT_SECTOR%’, @$user->employment_sector, $data);
$data = str_replace( ‘%ORGANIZATION%’, @$user->organization, $data);
$data = str_replace( ‘%COUNTRY%’, @$user->country, $data);
$data = str_replace( ‘%ADDRESS%’, @$user->address, $data);
$data = str_replace( ‘%ADDRESS_2%’, @$user->address_2, $data);
$data = str_replace( ‘%ADDRESS_3%’, @$user->address_3, $data);
$data = str_replace( ‘%CITY%’, @$user->city, $data);
$data = str_replace( ‘%STATE%’, @$user->state, $data);
$data = str_replace( ‘%ZIP_CODE%’, @$user->zip_code, $data);
$data = str_replace( ‘%NEWSLETTER%’, @$user->newsletter, $data);return $data;
}For example employment_sector is the name I’m using in the field for the form.
This is how I setup the email:
Contact Information
User Login: %USER_LOGIN%
User Email: %USER_EMAIL%
Display Name: %DISPLAY_NAME%
Username: %USERNAME%
Password: %PASSWORD%
Title: %TITLE%
First Name: %FIRST_NAME%
Last Name: %LAST_NAME%
Phone Number: %PHONE_NUMBER%
Fax Number: %FAX_NUMBER%
Occupational Information
Job Title: %JOB_TITLE%
Employment Sector: %EMPLOYMENT_SECTOR%
Organization: %ORGANIZATION%
Country: %COUNTRY%
Address: %ADDRESS%
Address (Cont): %ADDRESS_2%
Address (Cont): %ADDRESS_3%
Town / City: %CITY%
Region / State: %STATE%
Post / Zip Code: %ZIP_CODE%
E-News Bulletins and opportunities: %NEWSLETTER%
And this how I get the email:
User Login: Crash2040
User Email: crash.fflores@gmail.com
Display Name: Crash2040
Username:
Password:
Title:
First Name: Fabian
Last Name: Flores
Phone Number:
Fax Number:
Occupational Information
Job Title:
Employment Sector:
Organization:
Country:
Address:
Address (Cont):
Address (Cont):
Town / City:
Region / State:
Post / Zip Code:
E-News Bulletins and opportunities:
March 9, 2012 at 12:48 am #864KhaledMemberHi, I do some modification to umSetEmailController.php, hard coding for meta field is no more needed.
You need to add some line of code up-to version 1.1.1, Please follow those steps:
1. Open user-meta/framework/models/PluginFrameworkWPSupport.php
2. Find “insertUser” function, add those line before return statement of function:$userdata[‘ID’] = $user_id;
if( $userID )
do_action( ‘user_meta_after_profile_update’, (object) $userdata );
else
do_action( ‘user_meta_after_user_register’, (object) $userdata );3. Save files.
4. Download and unzip following zip file:
http://user-meta.com/files/2012/03/EmailController.zip5. This file contain umSetEmailController.php script, Upload umSetEmailController.php to wp-content/plugins/user-meta/controllers directory.
6. There will be new menu under User Meta in admin panel.
7. Update your setting. -
AuthorPosts
- You must be logged in to reply to this topic.