I have imported a large number of users from a Drupal based site into an newly created Elgg install. Everything went resonably well and the Elgg community has been really helpful when I bumped up against a couple of issues. So hopefully you can help me with this one... I have utilised the post_login_update plugin to make any new users registering automatically become a friend of a specific user which works perfectly but obviously this did not work with users I imported.
Is there anything I can do in the database to make all users be friends with a specific user or is there a plugin which does this and I missed?
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.
- DhrupDeScoop@Dhrup2000

DhrupDeScoop - 0 likes
- DhrupDeScoop@Dhrup2000

DhrupDeScoop - 0 likes
- Cash@costelloc

Cash - 0 likes
- shillo@shillog

shillo - 0 likes
- ChungNg@ChungNg

ChungNg - 0 likes
- shillo@shillog

shillo - 0 likes
- Ross Knight@RossKnight

Ross Knight - 0 likes
You must log in to post replies.be tom ;-)
shud import after plugin
If you know PHP, it should just be a few lines of code to do this (add relationships). Something like:
$users = get_entities("user", "", 0, "", 9999);
foreach($users as $user) {
add_entity_relationship();
}
Dear Cash,
Splendid, but please explain what the values represent in ("user", "", 0, "", 9999)
"user" is obvious. And the rest?
@shillo
The second parameter is "subtype" which is not applicable for entities of type "user" (first parameter), The third parameter is owner_guid, and the 4th parameter is the limit (of items you want on this call).
Which brings up a coding issue that has bothered me in all of the elgg engine calls regarding "limit". If you set the limit to 9999, then if you happen to have more than that number of users, you will miss the rest. In general the way I get around this is to have two loops as follows:
$total = 0;
for ( ; ; )
{
$newcount = 0;
$users = get_entities("user", "", 0, "", 9999);
foreach($users as $user)
{
// check to make sure relationship does not already exist then add it
add_entity_relationship();
$newcount++;
}
if ( $newcount == 0 )
break;
$total += $newcount;
}
That's wonderful, ChungNg.
I had the intution is that "9999" is the member limit, but don't worry, my site will never hit that barrier. There are not that many intelligent people on the planet :) hahaha.
Ok, thanks for this. I understand what is going on with code I can see the function referenced in elgg/lib/relationships.php but how best to go about running this. Sorry, I am a newbie!