Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)

  • whedlund
    Participant

    @whedlund

    Thanks for the tip about gist or pastebin.

    Unfortunately, I’m not a php guy (I used to code in VBA) so I don’t know enough about what you just gave me to make it work. I think I still have to call the fields, or is it going to be a total rewrite of the code example I gave above to make this work?


    whedlund
    Participant

    @whedlund

    To simplify my question, I’ve pasted the code in that Chris wrote. I just don’t know how to call the buddypress xprofile fields?

    /* ===========================================
    Send Emails when User Profile Changes
    =============================================*/

    // IF EMAIL CHANGES
    function sr_user_profile_update_email( $user_id, $old_user_data ) {

    $user = get_userdata( $user_id );
    if($old_user_data->user_email != $user->user_email) {
    $admin_email = "email@yourdomain.com";
    $message = sprintf( __( 'This user has updated their profile on the SchoolRise USA Staff Member site.' ) ) . "\r\n\r\n";
    $message .= sprintf( __( 'Display Name: %s' ), $user->display_name ). "\r\n\r\n";
    $message .= sprintf( __( 'Old Email: %s' ), $old_user_data->user_email ). "\r\n\r\n";
    $message .= sprintf( __( 'New Email: %s' ), $user->user_email ). "\r\n\r\n";
    wp_mail( $admin_email, sprintf( __( '[Staff Member Site] User Profile Update' ), get_option('blogname') ), $message );
    }
    }

    // Save old user data and meta for later comparison for non-standard fields (phone, address etc.)
    function sr_old_user_data_transient(){

    $user_id = get_current_user_id();
    $user_data = get_userdata( $user_id );
    $user_meta = get_user_meta( $user_id );

    foreach( $user_meta as $key=>$val ){
    $user_data->data->$key = current($val);
    }

    // 1 hour should be sufficient
    set_transient( 'sr_old_user_data_' . $user_id, $user_data->data, 60 * 60 );
    }
    add_action('show_user_profile', 'sr_old_user_data_transient');

    // Cleanup when done
    function sr_old_user_data_cleanup( $user_id, $old_user_data ){
    delete_transient( 'sr_old_user_data_' . $user_id );
    }
    add_action( 'profile_update', 'sr_old_user_data_cleanup', 1000, 2 );


    whedlund
    Participant

    @whedlund

    Great thanks.


    whedlund
    Participant

    @whedlund

    OK. I’m hearing you say I was right in my prediction and that there are three solutions.

    Unfortunately, your solutions are way over my head. How hard would it be for someone to create some sort of button that I can push or code I can run to do #3 for me that would be reliable?

    If it’s not a big job, i can probably pay someone to do that.

Viewing 4 replies - 1 through 4 (of 4 total)
Skip to toolbar