Reputation: 51
How to redirect user to a particular page after the user is successfully registered into the site?
Here drupal_goto()
does not work. We need to work with the form redirection. How can this be achieved?
Upvotes: 2
Views: 4035
Reputation: 51
// include the Url namespace in your custom module
use Drupal\Core\Url;
// Add CUSTOM SUBMIT HANDLER FOR REGISTRATION
$form['actions']['submit']['#submit'][] = '__tmp_registration_submit';
function __tmp_registration_submit(&$form, FormStateInterface $form_state) {
// set relative internal path
$redirect_path = "\user\uid\payment-history";
$url = url::fromUserInput($redirect_path);
// set redirect
$form_state->setRedirectUrl($url);
}
Upvotes: 2