Changing/Overwriting metadata, if the user is not the owner ?

It is possible, to update an objects metadata with an another user?

I tried to create the objet with the logged in user's guid in the object's owner_guid propertie.

and I tried to create the object with the owner_guid 0.

I found in both cases, that I cant update this object with an another user. I get an error is I trye to use $my_object->save();

How can I do this case right? I have to modify an object which is created by a user who can be anyone.

I thought, that the owner_guid = 0 is used for this, but maybe not.

Can somebody help me please?

(Sorry for my bad english!)

  • Wrap your code where you try to save an object in another user's name into

    $ignore = elgg_set_ignore_access(true);

    (your code comes here)

    elgg_set_ignore_access($ignore);

    This will override the default protection that would not let you edit objects owned by other users.

  • Andras has the right idea. You MUST make sure you bring the elgg_set_ignore_access back to false afterwards otherwise your site becomes somewhat "unprotected".