code: def invite_user_view(self):
          
  
          invite_user_form = self.InviteUserFormClass(request.form)
  
          if request.method == 'POST' and invite_user_form.validate():
              # Find User and UserEmail by email
              email = invite_user_form.email.data
              user, user_email = self.db_manager.get_user_and_user_email_by_email(email)
              if user:
                  flash("User with that email has already registered", "error")
                  return redirect(url_for('user.invite_user'))
  
              # Add UserInvitation
              user_invitation = self.db_manager.add_user_invitation(
                  email=email,
                  invited_by_user_id=current_user.id)
              self.db_manager.commit()
  
              try:
                  # Send invite_user email
                  self.email_manager.send_invite_user_email(current_user, user_invitation)
              except Exception as e:
                  # delete new UserInvitation object if send fails
                  self.db_manager.delete_object(user_invitation)
                  self.db_manager.commit()
                  raise
  
              # Send sent_invitation signal
              signals \
                  .user_sent_invitation \
                  .send(current_app._get_current_object(), user_invitation=user_invitation,
                        form=invite_user_form)
  
              # Flash a system message
              flash(_('Invitation has been sent.'), 'success')
  
              # Redirect
              safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_INVITE_ENDPOINT)
              return redirect(safe_next_url)
  
          self.prepare_domain_translations()
          return render_template(self.USER_INVITE_USER_TEMPLATE, form=invite_user_form)
docs: Allows users to send invitations to register an account