【问题标题】:Redirect user to specific website based on location when user clicks on webform pop up link当用户单击 webform 弹出链接时,根据位置将用户重定向到特定网站
【发布时间】:2018-05-21 17:37:37
【问题描述】:

我们在网站上有一个链接。

当用户点击链接时,会弹出一个在线表单。

客户希望如果美国以外的用户点击该链接,用户会被重定向到另一个网站。

这可行吗?

网站基于最新的 Drupal 8 版本,以防万一有一个模块可以做到这一点。

【问题讨论】:

标签: javascript php redirect url-redirection drupal-8


【解决方案1】:

你可以像这样使用表单 use hook_form_ID_alter。

function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  // get the IP address of user and determine where they are coming from
  // Follow this https://stackoverflow.com/questions/12553160/getting-visitors-country-from-their-ip
  // Redirect user
  // Follow this https://drupal.stackexchange.com/questions/146185/how-to-create-a-redirection-in-drupal-8
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-29
    • 1970-01-01
    • 2020-08-29
    • 1970-01-01
    相关资源
    最近更新 更多