0

I want to know where and how to plug/hook into profile 2, so that when the user updates a specific profile ("new_profile"), that this then fires off a chunk of custom php code. The event must only be fired off IF validation passes. Which leads me to believe that I can't really just add another submit handler.

How would I be able to fire off this "second update" to a seperate database, if I only want to hook into the part after validation has passed?

1 Answer 1

1

Every module which exposes hooks are documented in module *.api.php file. In your case it's just hook_profile2_update .

/**
* Respond to a profile being updated.
*
* This hook is invoked after the profile has been updated in the database.
*
* @param $profile
*   The $profile that is being updated.
*
* @see hook_entity_update()
*/
function hook_profile2_update($profile) {
  db_update('mytable')
    ->fields(array('extra' => $profile->extra))
    ->condition('pid', $profile->pid)
    ->execute();
}

Refer http://cgit.drupalcode.org/profile2/tree/profile2.api.php for more details.

1
  • This would work too, but I ended up adding an extra "submit" handler when the profile gets updated. Works just as well. Jan 14, 2015 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.