I am having a strange problem with the group subscription in Elgg. Not sure whether its a bug. So thought of first posting it here.
Have an Elgg install of Version 1.11.2 with only group, profile and notification plugins enabled. I am trying to create groupforumtopic via a simple script which has to be run without the user login. So I wrapped everything with in elgg_set_ignore_access() as below. But when I run this script, no group subscribers are getting notified about the new topic. If I create a topic after loging in, then the users are getting notified. Am I missing / overlooking something?
<?php
require_once(dirname(__FILE__) . "/engine/start.php");
$ia = elgg_set_ignore_access(true);$topic = new ElggObject();
$topic->subtype = 'groupforumtopic';
$topic->title = "Title";
$topic->description = "Description";
$topic->status = "open";
$topic->access_id = 2;
$topic->container_guid = 59;
$topic->owner_guid = 37;
if ($topic->save()) {
echo "Topic created";
}elgg_set_ignore_access($ia);
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.
- Juho Jaakkola@juho.jaakkola

Juho Jaakkola - 0 likes
- Juho Jaakkola@juho.jaakkola

Juho Jaakkola - 0 likes
- Juho Jaakkola@juho.jaakkola

Juho Jaakkola - 0 likes
- Steve Clay@steve_clay

Steve Clay - 0 likes
- aqeel@aqeel.mmd

aqeel - 0 likes
- Steve Clay@steve_clay

Steve Clay - 0 likes
You must log in to post replies.The notifications need an actor (someone who triggers the notification). If there isn't one, the notifications don't get sent.
I believe this is the line where the execution stops in your use case: https://github.com/Elgg/Elgg/blob/master/engine/classes/Elgg/Notifications/NotificationsService.php#L261
Actor defaults to the logged in user, so I don't think there currently is anything you can do.
One potential fix for the Elgg core might be to use $object->owner_guid as actor if actor is null on this line: https://github.com/Elgg/Elgg/blob/master/engine/classes/Elgg/Notifications/Event.php#L49
But that fix can be done earliest in one of the 2.x releases.
I reported an issue for this: https://github.com/Elgg/Elgg/issues/8864
For now you could set the logged in user during the script.
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.