Would it be possible for og_massadd to look up based on realname instead of username?
// If not, try to check for usernames
if (!isset($account) && drupal_strlen($mail)) {
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
->propertyCondition('name', check_plain($mail));
$result = $query->execute();
if (!empty($result)) {
$uids = array_keys($result['user']);
$account = user_load_multiple($uids);
$account = array_shift($account);
}
}
Already tried
->propertyCondition('realname', check_plain($mail));
I can see it's using EntityFieldQuery with propertyCondition but I don't understand if realname relates to entity properties or if there is any other way to check?
Any advise/help much appreciated.
UPDATE
Just found a way with drush to see available 'user' fields where realname isn't part of them :(
Any other way to cross check against realname?
UPDATE2
Found out that EFQ inner joins aren't supported but read about a workaround using subquery but couldn't make it work and are now stuck, any thoughts?
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
$rnames_subquery = db_select('realname', 'rn');
$rnames_subquery->fields('rn', array('uid'));
$query->propertyCondition('uid', $rnames_subquery, 'IN');
$result = $query->execute();
Managed to replace the query with a joined lookup