WP - private/password protected pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

WP - private/password protected pages

Post by simonmlewis »

Hi there
I need to be able to create product pages, that only customers who know the page is there, can see it.

The whole site will be banned from Google crawlers. But I need to be able to pass the product page URL to a customer, so they can see their private deal I am offering them.

I have tried 'Private', but that's only for the admin who is setting it to private to view it.
I've tried Password Protected, but that doesn't stop it being displayed in the Shop page of Woo Commerce.

Is there a nice simple plugin where you can assign from a dropdown, a product to a registered customer??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: WP - private/password protected pages

Post by simonmlewis »

Even if I could create a "group", ie, the company who is buying it, and then assign certain products to those certain groups/companies.... that would work. It's not a membership FOR THE SITE, it's specific bundle deals I put together, but I dont' want anyone to find it in the categories and see "Bobs Special Deal".......
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: WP - private/password protected pages

Post by Celauran »

simonmlewis wrote:I've tried Password Protected, but that doesn't stop it being displayed in the Shop page of Woo Commerce.
This seems to me to be the crux of the issue. Does WooCommerce expose any hooks? You could write a small plugin to exclude password protected products from the main shop page.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: WP - private/password protected pages

Post by simonmlewis »

I wouldn't know how to. It would need to do that for Search, Shop and Category. Oh and in "related products" on category.
There must be a way/plugin that you can hide products, and assign them into to certain accounts?????
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: WP - private/password protected pages

Post by Celauran »

Might be better to ask on dedicated WP boards if you're not keen on writing it yourself. I don't use WordPress much and don't use WooCommerce at all, so am in no position to tell you what plugins do or do not exist.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: WP - private/password protected pages

Post by simonmlewis »

I have - waiting for replies.
If it were a custom site that I built, it would be a doddle. But I'm surprised I cannot find a plugin that enables you to assign a product to a customer email address. So it's not seen on any normal pages, but if the customer logs in they can maybe see it in an account screen, or just access it via a given URL. Sounds pretty straight forward.

I know there are plugins that assign pages to user roles, but I don't believe you can "create" a user role. IF you could, then perhaps that Role could be a company name.. and hey presto.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: WP - private/password protected pages

Post by Celauran »

simonmlewis wrote:I know there are plugins that assign pages to user roles, but I don't believe you can "create" a user role.
You most certainly can.
New roles can be introduced or removed using the add_role() and remove_role() functions.
http://codex.wordpress.org/Roles_and_Capabilities
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: WP - private/password protected pages

Post by simonmlewis »

I don't see how to create a role. Let's say "Company A" is a new user role. How do I create that, and assign as "read" ?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: WP - private/password protected pages

Post by simonmlewis »

Bingo - got it. But then how do I assign a product to be seen only by that user role?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: WP - private/password protected pages

Post by simonmlewis »

You may not realise it, but you have really helped.

The Groups plugin for Wordpress means I can create a group. Then in the Edit product page, I can assign that product to the user.
What I will do, is create a category for "Members Products" and see if the Account holders products appear in there, dynamically. that would be very cool.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply