Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal hook_user stop execution

Tags:

hook

drupal

I need to use Drupal 6's "hook_user" to update a 3rd party API whenever a user updates their profile.

Therefore I use the 'update' operation. The problem I am facing is that I just cannot see how I can stop execution if the 3rd party API update fails.

I.e. the user updates their username, but if the API fails, prevent Drupal from updating the local record.

function myhooks_user($op, &$edit, &$account, $category) {

    switch ( $op )
    {

        case 'update':

            if ( FALSE === updateAPI($data) )
            {
                drupal_set_message("Cannot update user information", "error", false);

                return false; 
            }

            break;
    }
}

At the moment, the return false doesn't stop execution.

like image 213
JonB Avatar asked Jun 16 '26 18:06

JonB


1 Answers

There is not a way to stop execution.

You should be able to overwrite $edit, with what's in the db. That way there wont be any change. I haven't tried this out, but it should work just fine.

Why do you want to do this anyways? You could just add a row in the db, and update the profile at a later time with cron instead, to avoid frustrated users that need to do the same edit over and over.

like image 153
googletorp Avatar answered Jun 19 '26 20:06

googletorp