[development] Can I Indicate failure from hook_user?
Steven Jones
darthsteven at gmail.com
Mon Jul 21 10:23:16 UTC 2008
Always good to see someone new to Drupal.
Lots of hook return values.
You'll probably want to do something with the $op == "validate"
argument of hook_user. Throw an error if you don't want the
update/insert to continue.
Regards
Steven Jones
On Mon, Jul 21, 2008 at 10:26 AM, Pushyamitra Navare
<pushyamitra at gmail.com> wrote:
> Hello there,
>
> I'm new to Drupal, just started a couple of weeks ago. I had following
> queries regarding hooks. It would be great if someone could provide
> feedback/suggestions on this.
>
> 1. I have written a module which implements "hook_user" and handles "update"
> and "insert" operations. I want to be able to signal failure/ success from
> this function. For e.g. if I return failure (boolean FALSE) from "hook_user"
> for "update" operation, then user update should not happen. I want to do
> this for "insert", "update" and "delete" operations.
>
> * Is it possible to indicate failure in this way so that update/ insert/
> delete will not take place?
> * If yes, how can I accomplish this?
>
> 2. Also, I quickly glanced through the user.module. At the top there is a
> function called "user_module_invoke" which takes care of invoking
> "hook_user" in various modules. But it does not check for return value, nor
> does it return anything. So probably result of invoking a hook_user is never
> checked.
>
> If Drupal hooks currently don't check for return value, would it be good
> idea to add such a functionality? A "pre-operation" hook, which will
> indicate (boolean TRUE/ FALSE) if the operation should continue or not. Such
> a hook could be used for various validations when Drupal is integrated with
> some third-party applications. Any takers for this?
>
> Do reply.
> Thanks in anticipation,
> Pushyamitra
More information about the development
mailing list