开发者

Drupal hook_user stop execution

开发者 https://www.devze.com 2023-01-02 08:41 出处:网络
I need to use Drupal 6\'s \"hook_user\" to update a 3rd party API whenever a user updates their profile.

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($o开发者_StackOverflowp, &$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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消