Skip to:

How to pull user_email from database?

  • peterverkooijen


    I need this for a plugin/function. I can’t figure out how to do anything with the user_email during activation. When I do this:

    function synchro_wp_usermeta($user_id, $password, $meta) {
    global $bp, $wpdb;

    $email = $wpdb->query("SELECT user_email FROM wp_users WHERE ID='$user_id'");
    echo $email;


    add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);

    I only get the number ‘1’. I have no clue why. I’m clearly missing something obvious.

    If I can’t select the user_email on $user_id, how? The query works fine directly in the database. Do I need to change something in the PHP/Wordpress tagging system?

    Please help me out. I’ve been horribly stuck on this for the last 24 hours… :-(

    EDIT: Sorry, figured it out. Should have studied the codex. This works:

    $email = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE ID='$user_id'");
    echo $email;

    But I still don’t get why simply $user_email doesn’t work in that function…

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to pull user_email from database?’ is closed to new replies.
Skip to toolbar