From the course: WordPress Development: Coding Practice
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Hide content based on a query string - WordPress Tutorial
From the course: WordPress Development: Coding Practice
Hide content based on a query string
- [Instructor] If you want a super simple way to lock down content without a membership plugin, there is another solution. So here's the problem. We want to show content, but only if the URL shows that the user is a member. And we want them to be able to do this without a password. So what's our approach? Well, we'll look at the URL to see if there's a query string with a specific variable. So here are the requirements. Check the URL for a query string called "id." If "id" has any value, display the content; otherwise display a message that the content is restricted for members only. As a bonus, and we'll cover this in the solution as well, you can check for specific IDs. Note this is not the most secure way to do it, but it is a simple, passwordless solution. So with that, let's look at our starter code. Notice that there are two functions here, one to check the URL, and a filter for the content. Later, we'll also add…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Dynamic copyright year2m 50s
-
(Locked)
Randomize posts5m 37s
-
(Locked)
Get post meta3m 19s
-
(Locked)
Change admin colors based on the server5m 18s
-
(Locked)
Create your own block pattern5m 58s
-
(Locked)
Append a message to RSS content5m 31s
-
(Locked)
Sanitize input4m 39s
-
(Locked)
Sanitize output4m 4s
-
Add a sitewide banner to the top of the page3m 32s
-
(Locked)
Register a custom post type5m 37s
-
(Locked)
Store user meta5m 29s
-
(Locked)
Send an email to the admin when a plugin is activated6m 42s
-
(Locked)
When a user logs in, greet them by their name4m 44s
-
(Locked)
Create a transient5m 30s
-
(Locked)
Hide content based on a query string5m 49s
-
-