Redirecting Based on User ID(s) in Post Meta

This Pro tutorial provides the steps to redirect single post pages to a specific URL/location like the site's homepage if the user viewing the page is not the one set as the value of a custom field for that post.

Sample scenario:

CPT: service

Custom Field: access_user of the type User created using a plugin like ACF or Meta Box.

For a service titled say, "SEO" this custom field's value has been set to "John Smith".

When example.com/service/seo/ is viewed by anyone but John Smith, we shall redirect them to the homepage.

We are also going to cover the case where the custom field can contain multiple users.

This is a Pro members-only tutorial.

To get full access, login below or sign up for a Pro Account

Leave the first comment