Change access level ACCESS_LOGGED_IN to specific group

I want to move all content of an exist elgg instance that has access_id ACCESS_LOGGED_IN to a specific group, since a second type of users will be entering the site.

So I need to move the content first and then change the access_id

Does anyone has an sql script available for doing this ?


  • Can you just move all ElggObjects into a group regardless of the access_id or do you specifically need to move only the ones that have ACCESS_LOGGED_IN?

  • No, I don't think that is not possible. There is also public content like blogs who need to stay there.

  • I doubt there exists any scripts that do this.

    I quess you could use regular ElggBatch and then add a WHERE parameter in the params to be passed to elgg_get_entities:

    'wheres' = array("e.access_id = {ACCESS_LOGGED_IN}"),

    Then iterate through the results and change the container_guid.

  • Thanks Juho, since it is a one time thing. A SQL statement should be faster and more flexible. Who is the SQL guru in the core team. He should be able to help me out... It would be greatly appreciated

  • Was my question to hard ? There must be some one who can answer it.... I can't move forward in this project without knowing how to do this.

  • Not too hard, but your use case propably isn't generic enough so that someone would spend their making such script.

    "Moving" the content means that you change the container_guid. And then you change the access_id from ACCESS_LOGGED_IN to the ACL of the group.

    If you don't know how to do this, I recommend creating more specific forum topics. E.g. "How can I find out the ACL of a specific group". It's easier to get answers if you cut your goal into multiple smaller & more generic questions.

  • Juho, thanks. I must be able to figure that out myself indeed. It would have been much easier if someone who did this before would share it (as I do lots of times).

    For an experienced SQL guy, this is a matter of minutes and I will be spending hours and maybe days to figure this out.

    As to better discussions topics, I will try that too. There is very little to none (never sure about that) to find in the community on manipulating entitities in large volumes. I have many use cases for that :-)

  • I'm not sure anybody has ever had to do this before, it's a pretty specific use case

    UPDATE elgg_entities SET container_guid = {group_guid} WHERE access_id = 1 AND type = 'object'


    We try to discourage direct SQL manipulation, and for good reason.  You should probably test this out on a development version of your site or at the very least make a backup before attempting it as I can't be sure there won't be unintended consequences.

  • Thanks Matt, I will be trying this on my dev environment. If not, hope I can come back on it. I really understand SQL in principle, but have not much experience in manipulating it. There are really lots of cases we shoud want to do this, and if I do get a good understanding of the code I might built a plugin to do some real powerfull stuff.

  • Huh, well that turned out to be pretty simple.

    It's however still missing at least the new access_id (group_acl). Add it like this:

    UPDATE elgg_entities SET container_guid = {group_guid}, access_id = {group_acl_id} WHERE access_id = 1 AND type = 'object';