I am working on creating a small web-app with wordpress as the framework. It allows you to input a customer and in turn sends an email to the customer with a link back to the website in order to complete a short survey.
I have a “Customer” Custom Post Type which includes the survey questions as custom fields. I’m locking down the content and admin areas etc with s2member which so far has worked great.
However, I am after a way in which I can display a separate page which has the survey form on it and only display it for those which receive the link in an email. Possibly something with cookies and htaccess?
I’ve tried to find an answer for the last few hours but it’s a bit over my head. Any help even if just a push in the right direction would be greatly appreciated!
I think what you want is a custom rewrite rule — specifically, a custom endpoint.
This would have to live outside s2member.
To start, wrap everything in a class:
There are some constants there that we’ll use later.
You’ll need to modify your post type registration to include a custom endpoint mask in the
rewrite
argument.From there, we can hook into
init
and calladd_rewrite_endpoint
.This sets up a rewrite so we can go to
yoursite.com/customers/the-post/key/some_key_here
.Now it’s just a matter of hooking into
template_redirect
and validating the key.It might also be helpful to create a nice API to use (the above bit of code uses one of those methods).
Now you can use the above something like…
Not sure how well that will play along with s2member, but essentially this will block all access to the pages without a key on the front end. You may not need to restrict access with s2member at all. Here is all that as a plugin.
My (simple) solution would be put everything you need into
and everything in this
if
will be shown only for those who aren’t logged in.Posts can have password protected posts
post_password
column in the wp_posts table. Or you can use http://wordpress.org/extend/plugins/post-password-plugin/ to generate unique tokens.