PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Email Notification of profile updates

s2Member Plugin. A Membership plugin for WordPress®.

Re: Email Notification of profile updates

Postby Cristián Lávaque » August 19th, 2011, 1:08 am

Oh, I see. I'm glad you found the problem. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Email Notification of profile updates

Postby mnads » November 1st, 2011, 1:06 am

I could not get the code man-O-media posted to work. It sends me an email but does not print out any of my custom fields, does that code work for anyone else?

I tried to use the code below and it broke my s2member:
Code: Select all
    <?php
    add_action 
('ws_plugin__s2member_during_handle_profile_modifications''email_profile_changes');
    function 
email_profile_changes($vars = array())
    {
        
$user = new WP_User($vars['user_id']);
        
wp_mail ('me@me.net''Profile Update- ' $user->user_login'
        There has been an update to the user in the subject please verify. mysite.net/wp-login.php'
);
    }
    
?>
Last edited by Cristián Lávaque on November 2nd, 2011, 1:36 am, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
mnads
Registered User
Registered User
 
Posts: 4
Joined: November 1, 2011

Re: Email Notification of profile updates

Postby Cristián Lávaque » November 2nd, 2011, 1:42 am

What custom fields are you trying to send in the email?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Email Notification of profile updates

Postby mnads » November 2nd, 2011, 6:32 pm

This code email correctly but does not insert the values from the database.

Code: Select all
<?php
add_action 
('ws_plugin__s2member_during_handle_profile_modifications', 'email_profile_changes');
function email_profile_changes($vars = array())
{
    $user = new WP_User($vars['user_id']);
    wp_mail ('me@mydomain.com', 'Profile update - ' . $user->user_login, '
        Username: '
 . $user->mysite_wp_s2member_custom_fields['Username'] . '
        Email: '
 . $user->mysite_wp_s2member_custom_fields['Email'] . '
        First Name: '
 . $user->mysite_wp_s2member_custom_fields['First Name'] . '
        Last Name: '
 . $user->mysite_wp_s2member_custom_fields['Last Name'] . '
        middle: '
 . $user->mysite_wp_s2member_custom_fields['middle'] . '
        Suffix: '
 . $user->mysite_wp_s2member_custom_fields['Suffix'] . '
        Nickname: '
 . $user->mysite_wp_s2member_custom_fields['Nickname'] . '
        status: '
 . $user->mysite_wp_s2member_custom_fields['status'] . '
        Chapter: '
 . $user->mysite_wp_s2member_custom_fields['Chapter'] . '
        Grad: '
 . $user->mysite_wp_s2member_custom_fields['Grad'] . '
        Address: '
 . $user->mysite_wp_s2member_custom_fields['Address'] . '
        City: '
 . $user->mysite_wp_s2member_custom_fields['City'] . '
        State: '
 . $user->mysite_wp_s2member_custom_fields['State'] . '
        Zip: '
 . $user->mysite_wp_s2member_custom_fields['Zip'] . '
        country: '
 . $user->mysite_wp_s2member_custom_fields['country'] . '
        main_phone: '
 . $user->mysite_wp_s2member_custom_fields['main_phone'] . '
        secondary_phone_number: '
 . $user->mysite_wp_s2member_custom_fields['secondary_phone_number'] . '
        facebook: '
 . $user->mysite_wp_s2member_custom_fields['facebook'] . '
        linkedin: '
 . $user->mysite_wp_s2member_custom_fields['linkedin'] . '
        info: '
 . $user->mysite_wp_s2member_custom_fields['info'] . '
        terms: '
 . $user->mysite_wp_s2member_custom_fields['terms'] . '
        And so on...'
);
}
?>


These are the fields:
Username - non custom
Email - non custom
First Name - non custom
Last Name - non custom
-
middle - Text ( single line )
Suffix - Text ( single line )
Nickname - Text ( single line )
status - Select Menu ( drop-down )
Chapter - Select Menu ( drop-down )
Grad - Text ( single line )
Address - Textarea ( multi-line )
City - Text ( single line )
State - Select Menu ( drop-down )
Zip - Text ( single line )
country - Select Menu ( drop-down )
main_phone - Text ( single line )
secondary_phone_number - Text ( single line )
facebook - Text ( single line )
linkedin - Text ( single line )
info - Textarea ( multi-line )
terms - Checkbox ( single )
Last edited by Cristián Lávaque on November 2nd, 2011, 11:56 pm, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
mnads
Registered User
Registered User
 
Posts: 4
Joined: November 1, 2011

Re: Email Notification of profile updates

Postby Cristián Lávaque » November 2nd, 2011, 11:55 pm

Try without the mysite_ prefix:

Code: Select all
<?php
add_action 
('ws_plugin__s2member_during_handle_profile_modifications''email_profile_changes');
function 
email_profile_changes($vars = array())
{
    
$user = new WP_User($vars['user_id']);
    
wp_mail ('me@mydomain.com''Profile update - ' $user->user_login'
        Username: ' 
$user->wp_s2member_custom_fields['Username'] . '
        Email: ' 
$user->wp_s2member_custom_fields['Email'] . '
        First Name: ' 
$user->wp_s2member_custom_fields['First Name'] . '
        Last Name: ' 
$user->wp_s2member_custom_fields['Last Name'] . '
        middle: ' 
$user->wp_s2member_custom_fields['middle'] . '
        Suffix: ' 
$user->wp_s2member_custom_fields['Suffix'] . '
        Nickname: ' 
$user->wp_s2member_custom_fields['Nickname'] . '
        status: ' 
$user->wp_s2member_custom_fields['status'] . '
        Chapter: ' 
$user->wp_s2member_custom_fields['Chapter'] . '
        Grad: ' 
$user->wp_s2member_custom_fields['Grad'] . '
        Address: ' 
$user->wp_s2member_custom_fields['Address'] . '
        City: ' 
$user->wp_s2member_custom_fields['City'] . '
        State: ' 
$user->wp_s2member_custom_fields['State'] . '
        Zip: ' 
$user->wp_s2member_custom_fields['Zip'] . '
        country: ' 
$user->wp_s2member_custom_fields['country'] . '
        main_phone: ' 
$user->wp_s2member_custom_fields['main_phone'] . '
        secondary_phone_number: ' 
$user->wp_s2member_custom_fields['secondary_phone_number'] . '
        facebook: ' 
$user->wp_s2member_custom_fields['facebook'] . '
        linkedin: ' 
$user->wp_s2member_custom_fields['linkedin'] . '
        info: ' 
$user->wp_s2member_custom_fields['info'] . '
        terms: ' 
$user->wp_s2member_custom_fields['terms'] . '
        And so on...'
);
}
?>
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Email Notification of profile updates

Postby mnads » November 3rd, 2011, 9:17 am

Yes I tried that before as well, the code above does send the email but no values are present all I get is:

Username:
Email:
First Name:
Last Name:
middle:
Suffix:
Nickname:
status:
Chapter:
Grad:
Address:
City:
State:
Zip:
country:
main_phone:
secondary_phone_number:
facebook:
linkedin:
info:
terms:
And so on...
User avatar
mnads
Registered User
Registered User
 
Posts: 4
Joined: November 1, 2011

Re: Email Notification of profile updates

Postby Cristián Lávaque » November 3rd, 2011, 9:41 pm

Could you print_r($user) to see what the right key for the custom fields is?

Code: Select all
$user = new WP_User($vars['user_id']);
print_r($user); 
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Email Notification of profile updates

Postby mnads » November 3rd, 2011, 11:44 pm

Alright somehow I figured it out with the help of print_r($user);

<?php
add_action ('ws_plugin__s2member_during_handle_profile_modifications', 'email_profile_changes');
function email_profile_changes($vars = array())
{
$user = new WP_User($vars['user_id']);
wp_mail ('me@me.com', 'Profile update- ' . $user->user_login, '
Username: ' . $user->user_login . '
Email: ' . $user->user_email . '
First Name: ' . $user->first_name. '
Last Name: ' . $user->last_name. '
Middle: ' . $user->ss_dbprefixs2member_custom_fields['middle'] . '
Suffix: ' . $user->ss_dbprefixs2member_custom_fields['suffix'] . '
');
}
?>

Custom fields need ss_dbprefixs2member_custom_fields! Thanks for all your help Cristian!
User avatar
mnads
Registered User
Registered User
 
Posts: 4
Joined: November 1, 2011

Previous

Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 0 guests

cron