Which your Elgg version?
Since Elgg 3 we use Doctrine DBAL for SQL queries.
V 4.3.7
Try this:
$name = get_input('name', '');
$query = get_input('query', '');
echo elgg_list_entities([
'types' => 'user',
'metadata_name_value_pairs' => [
[
'name' => 'usertype',
'value' => 'driver',
],
],
'joins' => [
new \Elgg\Database\Clauses\JoinClause('metadata', 'em', function(\Elgg\Database\QueryBuilder $qb, $joined_alias, $main_alias) {
return $qb->compare("{$joined_alias}.entity_guid", '=', 'e.guid', ELGG_VALUE_INTEGER));
}),
],
'wheres' => [
function(\Elgg\Database\QueryBuilder $qb) use($name, $query) {
return $qb->merge([
$qb->compare('em.name', '=', $name, ELGG_VALUE_STRING),
$qb->compare('em.value', 'LIKE', '%$query%', ELGG_VALUE_STRING),
], 'AND');
},
],
'limit' => 5,
]);
On your questions:
1 - Why not? Just use a new way ;)
2 - Absolutely if you follow Elgg's code standards.
3 - Look at my example and the existing core and plugins' code. Ask here or welcome to Elgg chat in Telegram. We've a channel also.
For now you could set the logged in user during the script.
$session = elgg_get_session();
$session->setLoggedInUser($user);
$session->remove('guid');
// actions
$session->invalidate();
This "logs in" $user as far as Elgg is concerned, but prevents the GUID from being stored in the session.
If a browser hits this script, and actions fail, there'll be less chance that the browser would be left in a logged in state.
Note that anybody on the web can call your /cron triggers!
That worked steve. Thank you.
Why cant we use the owner_guid as the notifying user's guid value in such situations?
@aqeel See my comments on GitHub.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.