Hi all.
In Elgg 2.2 I had the following hook to auto-create group(s) after user validated by e-mail:
elgg_register_event_handler( 'validate:after', 'user', 'validate_event_handler', 9999 );
function validate_event_handler( $event, $object_type, $user ) {
if( $user ) {
elgg_set_ignore_access( true );
access_show_hidden_entities( true );
$data1 = $user->data1;
$data2 = $user->data2;
$groupname = $data1.' '.$data2;
$groupList = elgg_get_entities_from_attributes( array( 'type' => 'group', 'subtype' => 'subtype', 'attribute_name_value_pairs' => array( array( 'name' => 'name', 'operand' => '=', 'value' => $groupname, 'case_sensitive' => false ) ) ) );
if( is_array( $groupList ) ) $group = $groupList[0];
if( !elgg_instanceof( $group, 'group' ) ) {
$gdesc = 'Description';
$group_owner_guid = 293; //Owner of all auto-created groups with administrator privilege
$group = new ElggGroup();
$group->subtype = 'subtype';
$group->name = $groupname;
$group->description = $gdesc;
$group->membership = ACCESS_PRIVATE;
$group->setContentAccessMode(ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY);
$group->owner_guid = $group_owner_guid;
$group->save();
$group->access_id = $group->group_acl;
$group->save();
}
$group->join( $user );
access_show_hidden_entities( false );
elgg_set_ignore_access( false );
return true;
}
return false;
}
However, after upgrade to Elgg 2.3 this doesn't work any more. Help would be very much appreciated.
BR,
ZP
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.
- Steve Clay@steve_clay

Steve Clay - 0 likes
- ZdejPoham@ZdejPoham

ZdejPoham - 0 likes
- iionly@iionly

iionly - 0 likes
- iionly@iionly

iionly - 0 likes
- ZdejPoham@ZdejPoham

ZdejPoham - 0 likes
You must log in to post replies.Is your function called? Did you remember to turn off the email validation plugin back on?
The validation by email plugin is turned on. I don't know if the function gets called, could be the validate:after event was changed in 2.3. Whatever. Downgrading back to 2.2.
BR
ZP
Sorry. But I don't think the validate:after event even exists in Elgg 2.2 (or 2.3). It was added by https://github.com/Elgg/Elgg/commit/3b4fcbb2e67a51419ee64becb3d405071e5db689 to the master branch (future Elgg 3.0) but never in any 2.x branch.
And after reading https://elgg.org/discussion/view/2568003/how-to-perform-something-after-user-validates-registration-by-email I think you had customized your Elgg code to add this event yourself. So, it's quite clear that it won't work on Elgg 2.3 if you don't do the same customization again (if you would add it in your plugin code you wouldn't lose the modification when updating Elgg core...).
Oh snap! Thanks iionly! That was sufficiently long ago for me to forget about it. I'll have it fixed in no time thanks to you for pointing me in the right direction.
BR,
ZP