Page 2 of 2

Re: Email Notification of profile updates

PostPosted: August 19th, 2011, 1:08 am
by Cristián Lávaque
Oh, I see. I'm glad you found the problem. :)

Re: Email Notification of profile updates

PostPosted: November 1st, 2011, 1:06 am
by mnads
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'
);
    }
    
?>

Re: Email Notification of profile updates

PostPosted: November 2nd, 2011, 1:42 am
by Cristián Lávaque
What custom fields are you trying to send in the email?

Re: Email Notification of profile updates

PostPosted: November 2nd, 2011, 6:32 pm
by mnads
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 )

Re: Email Notification of profile updates

PostPosted: November 2nd, 2011, 11:55 pm
by Cristián Lávaque
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...'
);
}
?>

Re: Email Notification of profile updates

PostPosted: November 3rd, 2011, 9:17 am
by mnads
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...

Re: Email Notification of profile updates

PostPosted: November 3rd, 2011, 9:41 pm
by Cristián Lávaque
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); 

Re: Email Notification of profile updates

PostPosted: November 3rd, 2011, 11:44 pm
by mnads
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!