I had hoped to get back to this yesterday (and the day before), but you know, life happens… and in fact we’ve added another function to the whole process so now you get the whole kit and caboodle (you’re welcome).
So, just to bring you up to date, Sarah, a client of mine wanted to add a whole bunch of wholesaler functions to her WP e-Commerce store so in Part One we covered some of the plugins required to allow for a new Wholesaler role in her Users list and the addition of functionality to make that user just a little bit special.
To Recap – the issues to address in creating this scenario are -
- Creating a Wholesaler User Role and managing how to give it particular privileges – see Part One
- Being able to offer wholesaler discounts on the cost of store items - see Part One
- Having a payment gateway for wholesalers that allows for deferred payment/COD - see Part One
- Customising the Registration for to allow for custom fields like store name and address
- Customising the normal site login page with the Fabrik logo to create a more professional impression [edited: AND setting a re-direct to the Wholesaler Documents page]
- Creating a way of having content served specifically to wholesalers that isn’t available to ordinary shoppers
So now we get to play with some of the other cool functionality I used to extend the Wholesaler experience for both Sarah and the user.
4. Customising the Registration page to allow for custom fields.
I mentioned Gravity Forms in the previous post as an integral part of this process. Sarah was already using this plugin because it’s awesome and makes lovely, functional forms really easily. So I was stoked to find that the added functionality we needed was available as an add on and yes, I mentioned also that this add on is only available to users with a Developer license. (Seriously, it’s so totally worth it, as you’ll see below…)
Install the User Registration Add On (and if you don’t already have Gravity Forms active on your site, you’ll need to install that and activate it first).
The temptation at this point is to go to the User Registration section of the Forms menu and look at it… there’s nothing to see… you have to create a form first… SO
1. Create a form via the ‘New Form’ link in the Forms dashboard.
These are the fields we created for Sarah – they’re all either Advanced Fields that come pre-configured in Gravity, or Standard Text fields
Form Settings : Wholesaler Registration
Name of your Store/Business
ABN (Australian Business Number)
A little bit about your store (paragraph field).
In the form properties the Description Reads “Thanks for your interest in Fabrik! Please complete the form below and we’ll be in touch!” and the Confirmation reads “Thanks for contacting us! Your user account has been created.
Once your Wholesaler status has been approved you will be notified by email and will have full wholesale access.
Then create a page for your Registration form and insert the shortcode so that your form is displayed on the published page – I choose title=false because the page name doubles as the form’s title.
And here’s the published page.
This is all pretty standard fare for Gravity Forms. But if it’s not clear, ping me in the comments.
2. Now you go into the User Registration Settings and you map the fields in the form to fields in the database… don’t worry, it’s less complicated than it sounds… On the left of the page are the list of user settings created in your Wholesaler Registration form. On the right are the fields in the database you want to map your form to. Use the + and – buttons in the User Meta section to add or remove fields:
Here’s the screenshot:
There, so now when someone completes the registration form their data gets mapped into the database in a way WordPress understands, and puts it in places we can draw from – Hurrah!
Two things to note… we’ve set the username to be the client’s email address. It’s basically a safeguard that means we’ll get individual, unique, userids. Also, given that in the form we’ve set the default new user role to Subscriber, Sarah can log in to the back end, approve (or not) the application and upgrade the user role to Wholesaler and send a quick email to notify and welcome them.
5. Creating a custom logo for the login page and redirecting after login.
Given that Sarah’s inviting people to sign up for her site I deemed it necessary to customise the login page… just to make the process look a little bit professional… However, I took the path of least resistance on this one, because there are any number of plugins you can get hold of to really trick out the log in area. But, given that Sarah’s is a site with a really simple design and a lovely header image all I really wanted to do was use that header as a custom logo.
The first (and simplest) plugin I came across that looked suitable to do so was this one. ‘Login Logo by Mark Jaquith’ free from the WordPress Repository. All you have to do with it is “drop a PNG file named
login-logo.png into your
wp-content directory. This simple plugin takes care of the rest, with zero configuration. Transparent backgrounds work best. Keep the width below 326 pixels”.
How easy is that?? BAM… done… next?
Ok, after we’d deployed all of the above we noticed that once a new wholesaler logs in they immediately get redirected to their profile page… and for any new WordPress user it’s not immediately obvious how to get to the main site – So we wanted to make the site redirect to the Wholesaler’s documents page…
Again, there’s a plugin for that… it’s the charmingly named ‘Peter’s Login Redirect’ and it’s available here. There are a whole bunch of variables you can edit to determine who gets rerouted where… but for our purposes this is what we did. See? Way too easy!!
So now we’ve got wholesaler roles set up, and we’ve got application process underway… we’re on the homeward stretch. We need to serve the content ONLY to the wholesaling user…
6. Serving content to wholesalers only.
There are two elements required in this section… serving only the right pages to the wholesaler role and selectively showing wholesalers the links to those pages.
First, serving up the right pages is taken care of by the User Role Editor plugin… did you notice which options we selected in part one? One was Read Private Pages and the other was Read Private Posts… So that makes restricting pages really easy… you just set them to Private…
To restrict the links I’m using widgets. I started with creating two menus in Appearance » Menus one called wholesalers and the other login. To the wholesalers menu I added our two private pages. To the login Menu I added the wholesaler login and the wholesaler application page link.
Then I created added both of these menus as Custom Menu Widgets into my chosen Widget Area
Now, for the piece de resistance… I’m using the plugin Dynamic Widgets to take care of this final little bit of the business of restricting access to these menus … The plugin options are fairly heavy duty in terms of what you can show, where, and to whom, and for that it’s brilliant… however it does require the exercise of a little bit of logic to make sure you get the right widgets showing up on the right pages; trial and error gets one there in the end (just saying).
However, in this case the logic is ridiculously simple…
So access the Dynamic Widgets area either from the Appearance menu or from directly in the widget itself. Just click on the word static in the Wholesale Menu – you’ll be directed to the settings page, so in your specific widget under the Role options set the option ‘Show Widget to Everybody’ to NO with exceptions for Admin and Wholesaler roles like this…
So once that’s done… if someone’s logged in they’ll get to see the wholesale menu…
And in the log in menu make the settings the direct opposite of the above – Set Show Widget to Everybody to YES with exceptions for Admin and Wholesaler… so if they’re logged in as admin or wholesaler they don’t see the login menu but if they’re not, they can log in, or apply for wholesaler status.
Save the options and then click through to your site to try it all out!!!
Right, I think that about sums it up… Sarah now has a site with 2 audiences (well, three if you count the admin) and so far all seems to be working out for everyone concerned!!! I’ll report back if anything comes up or we need to edit the above, but the information should be plenty to get you moving off in the same direction if you need similar functions!
Hopefully it will prove useful out there in WordPress land… Chime in in the comments if you’ve anything to add!