Skip to:
Content
Pages
Categories
Search
Top
Bottom

check if field has new value in buddypress xprofile

  • @kumo99

    Participant

    When a user updates their profile field “Country” or “City” with a new value, I want to be notified with only the field that has new value. Currently I’m using this but doesn’t tell which fields have been modified:
    `add_action (‘xprofile_updated_profile’, ‘profile_change_notify’);
    function profile_change_notify ($vars = array ())
    {
    $user = new WP_User ($vars);
    wp_mail (‘myname@mydomain.com’, ‘Subject ( ‘ . $user->user_login . ‘ just updated the Profile )’, ‘Message Body goes here.’);
    }`

    I appreciate any help..

Viewing 1 replies (of 1 total)
  • @shanebp

    Moderator

    Untested, but try this:

    `
    add_action (‘xprofile_updated_profile’, ‘profile_change_notify’);
    function profile_change_notify ($id, $posted_field_ids, $errors) {
    $global $wpdb;

    if( $errors )
    return;

    $names = ”;

    foreach( (array)$posted_field_ids as $field_id ) {
    $sql = ” SELECT name FROM wp_bp_xprofile_fields WHERE id = ‘$field_id’ “;
    $name = $wpdb->get_var( $sql );
    if( $name == ‘Country’ || $name == ‘City’ )
    $names .= ‘ ‘ . $name;

    }

    if( $names != ” ) {
    $user = new WP_User ($id);
    wp_mail (‘myname@mydomain.com’, ‘Subject ( ‘ . $user->user_login . ‘ just updated the Profile )’, $names);
    }
    }
    `

Viewing 1 replies (of 1 total)
  • The topic ‘check if field has new value in buddypress xprofile’ is closed to new replies.
Skip to toolbar