I have a site that needs a redirect if a user tries to invite someone who is already a member. Instead of just showing an error I need it to redirect to /relationship/user id/request. How can I alter the following code to do that?

if (count($failed_emails)) {
        $error = format_plural(count($failed_emails), 'The following recipient is already a member:', 'The following recipients are already members:') . '<br />';
        foreach ($failed_emails as $key => $email) {
          $account = user_load_by_mail($email);
          $failed_emails[$key] = theme('username', array('account' => $account)) . ' (' . check_plain($email) . ')';
        }
        $error .= implode(', ', $failed_emails);
        drupal_set_message($error, 'error');
      }
    }

thank you for your time.

Comments

DevJoshLopez’s picture

Component: Documentation » Code
DevJoshLopez’s picture

Does anyone think this would be nicer then just an error saying the user is already on the site?

ckng’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)

Marked as duplicate of #1827624: redirect if failed