You are here

function redhen_contact_unlink_user_submit in RedHen CRM 7

Ajax callback for clearing a user from a contact.

_state

Parameters

$form:

Return value

mixed

1 string reference to 'redhen_contact_unlink_user_submit'
redhen_contact_contact_user_form in modules/redhen_contact/includes/redhen_contact.forms.inc
Return a form for managing contact/user links.

File

modules/redhen_contact/includes/redhen_contact.forms.inc, line 449
Forms for creating, editing, and deleting contacts.

Code

function redhen_contact_unlink_user_submit($form, &$form_state) {
  $contact = $form_state['redhen_contact'];
  $delete = $form_state['clicked_button']['#parents'][0] == 'delete';
  $wrapper = entity_metadata_wrapper('redhen_contact', $contact);
  $user = $wrapper->user
    ->value();
  $contact
    ->deleteUser($delete);
  drupal_set_message(t('The Drupal user %name has been %action from this contact.', array(
    '%name' => $user->name,
    '%action' => $delete ? t('deleted') : t('unlinked'),
  )));
}