How to get the previous URL in Form message

可紊 提交于 2021-02-08 11:40:09

问题


I am working on a WordPress site, where I have created a Contact Form.

So whenever someone clicks to apply for a job advert it takes them to a Contact Form

Example site - https://www.inext.se/job/solution-architect/

Application Contact Form - https://www.inext.se/job-apply-form/?id=6770

Now I am trying to get is the previous URL subject/title or the previous URL.

In JavaScript, I know it is possible to get it by -

<script type="text/javascript">
    document.write(document.referrer);
</script>

But I didn't find anywhere how to get in a form mail message body.

I have tried to use -

[_url]
[_post_name]
[_post_title]

But this gives me the form URL which is useless for me.

Do anyone know any solution!


回答1:


I think your best shot is to add a parameter in the URL from the page you are leaving. Doing that will bring the user to the new page with an extra GET parameter that can be your title/url.

With Cf7 you have a very ugly way to do that which is described here: https://contactform7.com/getting-default-values-from-the-context/

As long as your cf7 form item name equals the GET parameter name, you are good to go. The bad thing about this is that you have no pre-processing power and you need to pass values directly in the URL, w/o any encode (that's from what i know at least)



来源:https://stackoverflow.com/questions/64426854/how-to-get-the-previous-url-in-form-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!