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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With