Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当用户单击webform弹出链接时,根据位置将用户重定向到特定网站_Javascript_Php_Redirect_Url Redirection_Drupal 8 - Fatal编程技术网

Javascript 当用户单击webform弹出链接时,根据位置将用户重定向到特定网站

Javascript 当用户单击webform弹出链接时,根据位置将用户重定向到特定网站,javascript,php,redirect,url-redirection,drupal-8,Javascript,Php,Redirect,Url Redirection,Drupal 8,我们在一个网站上有一个链接 当用户点击链接时,会弹出一个在线表单 客户希望,如果来自美国以外的用户点击该链接,该用户将被重定向到另一个网站 这可行吗? 该网站基于最新的Drupal 8版本,以防有一个模块可以做到这一点。您可以像这样使用表单使用hook\u form\u ID\u alter function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id

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

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

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

这可行吗?


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

您可以像这样使用表单使用hook\u form\u ID\u 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
}

您可以检查生成带有链接的页面的请求的IP,使用IP地理位置确定它们所在的位置,然后根据它们所在的位置生成不同的链接。