I like the block implementation of the invite module, but why oh why does it have to redirect to /invite with tons of fields like custom message etc. I changed the menu item to redirect to my own custom page but then the invite function provided by the block does not work.. How can I hide all those custom message/from fields after they have used the invite block?

Thanks for any help..!

Comments

flefle’s picture

I just found out that while using the invite_block_form($remaining_invites) wit form action changed to the page subject and message fields are missing. This causes that the invite send function fails due the body and subject field missing.

Except of that the block functionality is not clearing the unset($_SESSION['invite_failed_emails']); so if you enter one wrong email, the next time the variable will make the form send fail.

DevJoshLopez’s picture

i would like to come up with a way to just send an invite quickly as well. I think it would be better for users to not have to fill in anything but an email field and click a submit button. Related to UX is another thing, I am also looking for a way to redirect on a failed attempt of the invite if a user is already in the system. This should just redirect to add the relationship to the user

akalata’s picture

Issue summary: View changes

Here's how I solved the "please don't redirect this form submission".

in a form_alter targeting $form_id 'invite_form':

foreach ($form['#submit'] as $key => $item) {
  if ($item == 'invite_form_submit') {
    $form['#submit'][$key] = 'mycustom_invite_form_submit';
  }
}
foreach ($form['actions']['submit']['#submit'] as $key => $item) {
  if ($item == 'invite_form_submit') {
    $form['actions']['submit']['#submit'][$key] = 'mycustom_invite_form_submit';
  }
}

Then I copied and edited invite_form_submit:

function mycustom_invite_form_submit($form, &$form_state) {
  $invite = $form_state['invite'];
  entity_form_submit_build_entity('invite', $invite, $form, $form_state);
  invite_save($invite);
}