Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profile Fields show on email to admin?

  • Avatar of richprice316
    richprice316
    Member

    @richprice316

    Hi, been using buddypress for a few months now, it is superb. I have profile fields installed which register displays. Results come up in profile pages, great.

    But when the email comes through to admin, it just says the new user is (name & email address). we are pre appproving members as the site is a community for kids. We need to see all the data before we click the approve member (we use the “confirm user registration” module).

    Is there a way for the profile fields can show up on the email? this would solve all of our problems.

    thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    You need to override the new user admin email function:
    http://codex.wordpress.org/Function_Reference/wp_new_user_notification

    Then you need to call on some BuddyPress functions to grab the xprofile data.

    xprofile_get_field_data() (located in bp-xprofile.php) will help.

    If all this is foreign to you, short answer is “it’s possible, but requires coding” ;)

    Avatar of richprice316
    richprice316
    Member

    @richprice316

    if you got a step-by-step or could elaborate further on this I would appreciate it mate.

    You are the first person to make me feel like this is even possible thank you!

    I am very new to php and buddypress etc so trying my best but not quite to the levels you are speaking of

    Avatar of saijin_nxtoyou
    saijin_nxtoyou
    Member

    @saijin_nxtoyou

    I tried xprofile_get_field_data() but it didn’t work, maybe I’m just too dumb.. :)

    So I tried it using MySQL, here is my function wp_new_user_notification, I edit wp-includes/pluggable.php

    function wp_new_user_notification($user_id, $plaintext_pass = ”) {
    $user = new WP_User($user_id);

    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);
    $buddypress_fields = $user_id;

    // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    // we want to reverse this for the plain text arena of emails.
    $blogname = wp_specialchars_decode(get_option(‘blogname’), ENT_QUOTES);

    $message = sprintf(__(‘New user registration on your site %s:’), $blogname) . “rnrn”;
    $message .= sprintf(__(‘Username: %s’), $user_login) . “rnrn”;
    $message .= sprintf(__(‘E-mail: %s’), $user_email) . “rnrn”;

    // Add Custom Fields from buddypress table to admin email – Start

    $buddypress_result_ = mysql_query(“SELECT
    wp_bp_xprofile_fields.name,
    wp_bp_xprofile_data.value
    FROM wp_bp_xprofile_fields, wp_bp_xprofile_data
    WHERE
    wp_bp_xprofile_data.user_id = $user_id
    AND
    wp_bp_xprofile_fields.id = wp_bp_xprofile_data.field_id
    ORDER BY
    wp_bp_xprofile_data.field_id”);

    while($buddypress_row = mysql_fetch_array($buddypress_result_))
    {
    $fields = $buddypress_row;
    $fields_value = $buddypress_row;
    $message .= $fields . “: rn”;
    $message .= $fields_value . “rnrn”;
    }

    // Add Custom Fields from buddypress table to admin email – End

    @wp_mail(get_option(‘admin_email’), sprintf(__(‘[%s] New User Registration’), $blogname), $message);

    if ( empty($plaintext_pass) )
    return;

    $message = sprintf(__(‘Username: %s’), $user_login) . “rn”;
    $message .= sprintf(__(‘Password: %s’), $plaintext_pass) . “rn”;
    $message .= wp_login_url() . “rn”;

    wp_mail($user_email, sprintf(__(‘[%s] Your username and password’), $blogname), $message);

    }

    Avatar of Stefan83
    Stefan83
    Participant

    @stefan83

    I’m also looking to do this. I realise this is an old post so there may be an easier way to add xprofile data to the wp user registration admin emails? I’ve tried searching but can’t find anything. Can anyone help? Thanks

    Avatar of kizzywizzy
    kizzywizzy
    Participant

    @kizzywizzy

    @stephan83 This worked for me in BP 1.6.
    `
    add_filter(
    ‘bp_core_signup_send_validation_email_message’,
    ‘add_user_data_to_message’,
    10,
    2
    );

    function add_user_data_to_message( $msg, $user_id )
    {
    $user = get_user_by( ‘id’, $user_id );
    return $msg . “\n\n” . var_export( $user, TRUE );
    }
    `

    Avatar of Stefan83
    Stefan83
    Participant

    @stefan83

    Thanks for your reply kizzywizzy! I’ve added this code to the functions.php file but this adds some of the user data to the users activation email which is not what I want. Like this:

    `WP_User::__set_state(array(
    ‘data’ =>
    stdClass::__set_state(array(
    ‘ID’ => ’827′,
    ‘user_login’ => ‘user’,
    ‘user_pass’ => ‘password’,
    ‘user_nicename’ => ‘stefanlesik’,
    ‘user_email’ => ‘email’,
    ‘user_url’ => ”,
    ‘user_registered’ => ’2013-02-18 17:05:46′,
    ‘user_activation_key’ => ”,
    ‘user_status’ => ’0′,
    ‘display_name’ => ‘user’,
    )),
    ‘ID’ => 827,
    ‘caps’ =>
    array (
    ‘subscriber’ => true,
    ),
    ‘cap_key’ => ‘wp_capabilities’,
    ‘roles’ =>
    array (
    0 => ‘subscriber’,
    ),
    ‘allcaps’ =>
    array (
    ‘read’ => true,
    ‘level_0′ => true,
    ‘subscriber’ => true,
    ),
    ‘filter’ => NULL,
    ))`

    I’d like to display the all the xprofile data in the new user registration email that admin receives. Is this possible?

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

You must be logged in to reply to this topic.