• Home
  • About
  • Now
  • Code Snippets
  • Blog
    • WordPress
    • Genesis Theme Framework
    • Tutorials
    • Web Development
    • Geeking Out
    • Blogging Resources
  • Contact
  • Home
  • My Story
  • Now
  • Code Snippets
  • Blog
  • Contact

The Web Princess

WordPress & Genesis Theme Development

The Web Princess

Creating a Wholesaler Role in WP e-Commerce – Part Two

February 17, 2012 by Dee Teal

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 –

  1. Creating a Wholesaler User Role and managing how to give it particular privileges – see Part One
  2. Being able to offer wholesaler discounts on the cost of store items – see Part One
  3. Having a payment gateway for wholesalers that allows for deferred payment/COD – see Part One
  4. Customising the Registration for to allow for custom fields like store name and address
  5. 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]
  6. 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
Email
Name of your Store/Business 
Store Address
Phone Number
ABN (Australian Business Number)
Website
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.

Thanks!

Sarah”

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.

Edit-Page--Fabrik--WordPress

And here’s the published page.

Wholesaler-Application

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:

User-Registration-Fabrik--WordPress-1

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”.

Fabrik--Log-In

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!!

Login_logout-redirects-Fabrik--WordPress

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…

Edit-Page--Fabrik--WordPress1

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.

Menus-Fabrik--WordPress-1

Then I created added both of these menus as Custom Menu Widgets into my chosen Widget Area

Widgets--Fabrik--WordPress-2

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.

Edit-Page--Fabrik--WordPress

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!

About Dee Teal

Dee Teal is a Scrum Master, Project Manager, and Team leader with a history as a developer (mostly front-end and using the Genesis Theme Framework) and WordPress trainer who is crazy active in the WordPress community.

She's run large scale WordPress events, and small ones, and if you ask someone about WordPress in Australia, you won't usually be more than one degree of separation from someone who knows her.
 
You can also find her here...
LinkedIn | Twitter

Comments

  1. DIego says

    February 28, 2012 at 4:37 pm

    Hello! your post was all that I was looking for! I done lot’s of research and no plugin does this out of the box, some come close but are imperfect. I have one question, do you think this could work with the getshopped members only plug in? The wordpress roles along with the gravity forms seems to work really cool but 199 is expensive and the members only plug in is 49.99, any thoughts?

    • Dee says

      March 3, 2012 at 12:07 pm

      Hi Diego, sorry for the delayed reply!

      I genuinely don’t know, I’ve never used the WP members plugin – but I’ll send my post to the guys at Instinct and ask them, it’s a good question 🙂

      • DIego says

        March 3, 2012 at 12:10 pm

        That would be really awesome!! thank you so much! No worries on the delayed response! you got back to me that is what counts! cheers

      • arno says

        September 23, 2012 at 7:30 am

        Hi Dee
        did the guys at Instinct replied to you? Is it possible with the members only plugin?
        Thank you very much for this tut btw

        arno

  2. Andrew says

    April 10, 2012 at 11:34 am

    Not only is this an accurate and detailed tutorial, it totally works, and as a designer/hack it was the exact solution I was looking for. Thanks Dee. My mantra and daggy email signature has been “What you learn, teach. When you get, give.”, and this is a perfect iteration of this.

    On another note, I was looking for a way to make the User Registration Add-on custom fields public, and nothing seems to do the exact job. Out of the box, it seems like Profile Builder comes the closest, but the additional fields do not display or are editable.

    Gravity Fields is great, and well worth the coin for the power – I just wish that it auto-updated to Campaign Monitor when you edited the User Registration entry in GF Entries.

    Thanks again, Brilliant tut.

FREE Website Planner

  • Become your web designer's favourite client

Website Sign Ups

Become your Web Designer's favourite client by preparing for your web project using the Web Princess' Interactive Website Planner

  • This field is for validation purposes and should be left unchanged.

Tweet

  • I just solved pack Snake in WordBrain - as number 2605 ever! #wordbrain #genius #words http://t.co/ygULwZTRYQ http://t.co/ORNxwtaTIl September 14, 2015 2:11 pm
  • Pretty impressed with the stops that @Telstra are pulling out to get my issues sorted... Service with a surprised smile! September 14, 2015 2:48 am
  • It's Tuesday. A perfect evening for this. And by this I mean beer (of course). #oohermrs… https://t.co/eiIttD5xWa September 8, 2015 8:17 am
  • Follow Along

Recent Posts

  • Moving to deeteal.com October 23, 2020
  • Asking a Better Question September 13, 2016
  • Growing & Developing your WordPress Meetup June 24, 2016
  • Making an Escape June 7, 2016
  • Changing Tack : Adjusting your Sails for the Winds of Change May 7, 2016
  • Privacy Policy
  • Disclosure Policy
  • Contact

© 2023 The Web Princess
Proudly custom built with Genesis