I have widgets on my home page, I also have a landing page with subscribe form. when a user does subscribe, he redirects to home page. The home page is also available via the link to view.

The homepage has complete setup having different widgets and text.

Now I want when user fill subscribes form and he redirected to the homepage, a specific widget in footer must be disabled, while if the user comes to homepage directly all the widgets must be available.

Kindly help me, a thought coming to me this can be done via sessions like I can maintain a session when user come from subscribing page and on the home page I check if the session value matches I will hide widget.

But can you suggest a proper way or plugin do this thing that will help me?

  • For all server-side answers, keep in mind that it will break if you have output caching enabled.
    – janh
    Commented Jan 25, 2018 at 12:58

2 Answers 2


There is a function called wp_get_referrer that you can use to see from which page a user is reaching the home page. Usage:

if (is_home() && (wp_get_referrer() == 'url/subscription/page')) {
  ... show page without widget
else {
  ... show page with widget

Now, there is no built in way to use this condition to show/hide a widget. So, there are roughtly two possibilities:

  1. If you have built the widget yourself, you can put the condition inside the widget and show nothing if the condition is met.
  2. Otherwise, your best course of action is to build a child theme where you conditionally register a sidebar to put the widget in. If the condition is met, there will be no sidebar and hence no widget.

The easiest solution is using WordPress plugin. You can use Widget Options for WordPress to hide the widget. Using the Display Widget Logic feature you can add (is_home() && (wp_get_referrer() == 'url/subscription/page')) as value. Refer to the screenshot below.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.