Hi guys, I am having trouble of getting the ID in user_register filter in functions.php...
Here is what I got
add_action( 'user_register', 'sendanotheremail' );
function sendanotheremail($user_id) {
$user = new WP_User($user_id);
$user_login = stripslashes($user->user_login);
$user_email = stripslashes($user->user_email);
$get_id = $user->ID;
global $wpdb;
$getunion = $wpdb->get_results("SELECT value from wp_bp_xprofile_data where user_id = $get_id AND field_id = 4", "ARRAY_N");
$message = sprintf(__('New user registration on %s:'), get_option('blogname')) . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
$message .= "<br /> Please go here to approve the new user <a href=\"http://xxx.com/wp-admin/admin.php?page=bp_registration_options_member_requests\">Approve/Deny</a>";
if(!($getunion)) {
$message .= "nothing there";
}
else {
$message .= "yes";
}
$headers = 'From: xxx <xxx@xxx.com>';
add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));
wp_mail('xxx@xxx.com', 'New User Registration to xxx website', $message, $headers);
}
I am testing the getunion if its empty I am returning "nothing there".
So all of the other variables are getting me email with right data, but $getunion is empty...
When I pass manually the ID here
$getunion = $wpdb->get_results("SELECT value from wp_bp_xprofile_data where user_id = $get_id AND field_id = 4", "ARRAY_N");
it works... So how can I get the ID?