Quote:
FAQ:
* What happens if a user is deleted in G2 (e.g. with GalleryEmbed::deleteUser())?
All items of the user get reassigned to a new owner, usually to the first admin in the admin list. The user itself is completely deleted.
What function (or API method) should I use if I want all user items to be deleted with user?
Thanks,
Posts: 151
After calling GalleryEmbed::init, before you call GalleryEmbed::deleteUser(), use this code:
'user_id' = ID of the user being deleted
'your_user_id' = your User ID (or the User ID of another user who has Site Admin priveleges in Gallery) - this is required because you can't call deleteUserItems unless you're a site admin.
You can expand that to your liking (adding error handling, etc.).
The Oldiesmann
SMF Support Specialist
SMF+G2 Integration Project
Posts: 15
Hi again,
Somewhy my code does not delete the user - can you tell me why?
Because $user->getid(); returns valid user id (number) that should be deleted, I suspect that the GalleryCoreApi::deleteUserItems($user->getid()); and GalleryEmbed::deleteUser($user->getid()); are not working. Or... do I have to execute or commit the changes somehow?
Thanks,
Posts: 15
problem solved.
Posts: 32509
just FYI:
the default policy of g2 is to reassign all items of the user to a new owner instead of deleting them.
the new owner is the first admin it finds by default.
the admin UI of g2 allows to specify another new owner. it also allows to specify that all items should be deleted.
so if you do an integration, decide what behavior you want and implement the code appropriately. be sure to communicate this to your users.
Posts: 15
Hi again,
I don't fully understand how to deal with $ret errors? For example, the code below gives me PHP error:
Fatal error: Call to a member function isError() on a non-object in E:\Projects\g2_myapi\embed.php on line 26.
Thanks,
Posts: 7
As far as I know (I am no expert) $ret is an instance of a gallery return object, which has a few methods, such as getAsHtml. One method it does not have is isError(). $ret itself acts as a sort of boolean, so all you need to do in your code is:
The return object will return true if there has been an error of some sort. Then you can deal with it. I've been subscribing to this thread because I have written a little script with this exact same functionality in my G2 integration. Here it is, perhaps it will be helpful:
I have an administration script which has a couple text entries. The first is a big textarea that the admin is supposed to paste the account names into, seperated by commas (name=deletionBlock). Then there are two checkboxes, one that says "Really do this? This will DELETE THE USERS" (name="reallyReally") and another that says "Also delete user's items"(name="deleteStuff"). The script works like a charm, all that stuff really does get deleted.
Good luck with your G2 integration,
- Geddes
Posts: 32509
$ret is null unless there was an error.
if ($ret) {
// something bad happened.
print $ret->getAsHtml();
exit;
}
// else everything is fine.