1

I'm running wpmu on heroku using a postgres extension. It works great, but I have a plugin that needs to get the userId based on the e-mail-adress. This is how it does it:

$sql = 'SELECT id FROM ' . $wpdb->users . ' WHERE user_email=\'' . addslashes($from) . "' LIMIT 1;";
$user_ID = $wpdb->get_var($sql);

$wpdb->get_var($sql) returns nothing. I'm trying to figure out why.

1 Answer 1

3

The plugin should use the API, not some made-up SQL. addslashes() is not safe enough anyway.

$user = get_user_by( 'email', '[email protected]' );
echo $user->ID;

Besides that, the user tables are almost the same, there are just some tighter restrictions for user names in multi-site, because new sub domains could be made from the names.

1
  • 1
    lot's of coding love! I'll send him a patch! Commented May 6, 2013 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.