I'm creating a module that creates user accounts relative to those stored on a server. The module is going to look at the accounts stored on the server and make sure they are the same as in Drupal. So if an account is disabled on the server it will be disabled in Drupal, if the user belongs to a different group and his or her permissions are changed, they will change in Drupal, and so on. I can create the accounts just fine, but because this is something that will run every hour, I want to check to make sure that if an account already exists that Drupal doesn't try to create it again, otherwise I'll constantly get a 'duplicate entry' error every hour. Just wondering if there is a simple function in order to check if a user exists. I've looked at the hook_user and save_user functions, but just wondered if anyone else has any other suggestions.
Thanks,

Zee

Comments

syedz’s picture

okay so I found the user_load function. But I have another question, how do I disable a user? Is there a function that allows you to edit user account settings? I know that there is the user_edit function, but I'm too sure how to use it :S, any help would be appreciated.
Thanks

Zee

pbarnett’s picture

Check the functions in the user module and the API documentation for them, like http://api.drupal.org/api/function/user_edit/6