How to check http referrer user Google sear result display shortcode

[ad_1]

Hello everyone, I have a question that I hope can be guided and answered.

My website is made with WordPress and has a shortcode that looks like this

`[promotion]`

I want to check if the user accesses from Google search and displays the short code above.

If false don’t display it

Currently I have tried checking the http referrer with the following code:

`<?php`
`// Check if Referral URL exists`
`if (isset($_SERVER[‘HTTP_REFERER’])) {`
  `// Store Referral URL in a variable`
  `$refURL = $_SERVER[‘HTTP_REFERER’];`
  `// Display the Referral URL on web page`
  `echo $refURL;`
`} else {`
  `echo “No referer URL”;`
`}`
`?>`

But it only checks the referrer from Google which is OK. I want it to check if the correct user from Google search then displays the short code **\[promotion\]**. Otherwise, the short code will not be displayed.

Can AI help me do this?

Regards.

Toi Duy

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer