I am just wondering if there’s a plugin out there that does anything like this. Have had no joy so far.
1. Site admin creates a list of secret words, each one associated with a hidden page.
2. Site user clicks on an “access hidden content” page and is prompted to enter a secret word.
3. If the entered word matches a word on the list, its associated hidden page will be displayed to them.
There are lots of simple “password-protect” plugins, but I haven’t found one with the ability to load a different page depending on what password is entered.
There are also some very fully-featured site membership plugins which could probably be twisted into doing something like this but seem like overkill.
All suggestions very gratefully received.
[ad_2]
The right solution would be a php function linked to a simple text-entry. Store the secret words in the database, optional to store as pairs with id/url of target page. Then something like:
`<div>`
`<form name=”secretThings” method=”post” action=”/wp-admin/admin-post.php”>`
`<input type=”hidden” name=”action” value=”my_funtion_name” class=”form-control”/>`
`<input type=”text” placeholder=”password” id=”pw_check” name=”pw_check”>`
`<input type=”submit” name=”sendSecret” class=”form-control”>`
`</form>`
`</div>`
`function check_secret_thing() {`
`$pw_entered = $_POST[‘pw_check’]; // get the word they entered`
`// get the array from e.g. wp_options and check if their word is in it, if so go to X page`
`}`
`add_action( ‘admin_post_my_funtion_name’, ‘check_secret_thing’ );`
This form lets you submit one word, which is passed to the function.
A slight hack would be to have a redirect plugin… simply add a template redirect in the above function:
wp_safe_redirect(‘/’ . $pw_entered . ‘/’);
And a redirect plugin to send each request to the right page – any ‘invalid’ entries – the redirect can send all of them to a ‘nope – wrong password’ page or whatever.
But if this is too much, you can get a form plugin which allows conditional notifications. Then a LOT of ‘if form entry X = “thisWord” redirect to page Y’
Gravity / fluent forms / ninja / wpforms / formidable can do this, but you need a paid version. I don’t think you’ll get it free – or in a plugin.