You are here

function rules_forms_action_redirect in Rules Forms Support 7.2

Same name and namespace in other branches
  1. 7 includes/rules_forms.eval.inc \rules_forms_action_redirect()

Action: Set the redirect target.

Parameters

RulesFormsFormStateWrapper $form_state: A reference to the form state array of the form for which the event was triggered.

string $path: The path to which to redirect the user.

string $query: A query string for use in drupal_goto().

string $fragment: A fragement string for use in drupal_goto().

1 string reference to 'rules_forms_action_redirect'
rules_forms_rules_action_info in ./rules_forms.rules.inc
Implements hook_rules_action_info().

File

includes/rules_forms.eval.inc, line 202
Evaluation functions for Rules Forms module.

Code

function rules_forms_action_redirect(RulesFormsFormStateWrapper $form_state, $path, $query, $fragment) {
  $form_state = $form_state
    ->value();

  // We manually check the form to see if redirect is okay.
  // Setting $form_state['redirect'] has proven to be unreliable.
  if (!empty($form_state['programmed']) || !empty($form_state['rebuild']) || !empty($form_state['no_redirect'])) {
    return;
  }

  // Check if a query was defined and build the options array.
  $options = $query != '' ? array(
    'query' => array(
      $query,
    ),
  ) : array();
  $options['fragment'] = $fragment;

  // Redirect the user.
  drupal_goto($path, $options);
}