New Pluralsight Course: User Roles & Capabilities in WordPress

I’ll tell you a secret: up until a few months ago, user roles and permissions in WordPress were a vast, unexplored land of confusing terms (capabilities and — gasp — meta capabilities) and complex relationships. I didn’t know much, but I did know that if you were playing with new user roles or capabilities and messed up how you handled things, you could seriously break stuff for yourself or your site’s (or plugin’s) users. As a former Mirosoft Windows geek — who did support for Windows and applications running on Windows — it was a lot like the registry; sure, you can do some amazing stuff by hacking the registry, but if you break it, you’re screwed.

I also knew they could be incredibly powerful, especially if you wanted to create an environment where everyone isn’t an admin. Which, you know, should be like every site. Ever.

So, when I sat down to start writing my Book Review Library plugin, I was thinking about my target audience — two librarians who I worked with to hash out the specific features that they wanted for this new addition to a school website. They wouldn’t want — and shouldn’t have — admin access to everything. But if I didn’t make them admins, they wouldn’t be able to create book reviews, which were the thing they were asking for. Which is when I started looking at creating new user roles that would only be able to access those reviews and other areas that I thought they should be able to access.

And that’s the crux behind my new Pluralsight course — Master Your Domain: User Roles and Capabilities in WordPress. I wanted to go through the existing user roles system in WordPress, how you can leverage those existing roles to give site users access to only those parts of the site that they are going to be using, and how to extend those existing roles by adding new permissions (capabilities) to them or by creating new user roles. And here’s another secret: it’s really not that scary. If you get custom post types, you’ll get custom user roles and user meta, trust me.

Another giveaway

Okay, so to commemorate the new course, I’m doing another giveaway for 1 month trial codes for Pluralsight. This time around, I’m limiting them to 5. Once I’ve given away 5, there will be no more (until I do another giveaway). Want a month of free Pluralsight so you can check out my new course? Sure you do. This time I’m using Rafflecopter and letting it deal with all the details and stuff. It’s pretty easy — follow me on Twitter, tweet about the course, then post a comment back here about what other WordPress-related topics you’d like me to cover. You can also follow Pluralsight on Twitter so you know about new courses and stuff.

a Rafflecopter giveaway

What I’m working on: building a plugin for book reviews

Last year, I met with some of the peeps from the Open Classroom‘s School Library (and Library Committee) to come up with ideas for how the Open Classroom website could better serve them. This was part of an existing process I was going through for planning the update to the website that I launched a couple weeks ago and you can check out now. (WordPress peeps might notice it’s using ThemeID‘s (now CyberChimps‘) Responsive theme as a base. Ironically, I had to make the Responsive theme actually “responsive”, but that’s a topic for another post…) What came out of that conversation was the foundation for a complex, custom post type-based plugin that uses a wide variety of custom taxonomies that would be used for sorting books (and book reviews) by a variety of different things, from genre to subject to authors and illustrators to reading level. I’m entering the final stages of development for the plugin where most of what needs to be done will be some front end and UX stuff, so I’m excited to show off some screenshots of the stuff I’ve been working on. Here we go.

The menu

Book Review menu

The first thing is the menu. A fairly standard WordPress menu. What’s interesting to point out here is that I’m using the Genericons icon font as the dashboard menu icon for the custom post type. I did this because when the WordPress dashboard gets overhauled in 3.7 (or 3.8?), all the menu icons will no longer be the sprite-base images we’re used to seeing, but will instead be using the Dashicons icon font which was specifically built for the WordPress dashboard. This makes the icons more scalable and beautiful on retina devices and also corresponds to the “flat” design of the new layout. So, I decided to get a head start on it now. However, in order to do so with the current version of WordPress, I had to do some clever CSS hacking to hide the existing icon and replace it with a specific character from a font I am loading in the dashboard. I posted the (CSS) code for that in a Gist yesterday.

Review Authors, Genres, Book Authors, Reading Levels, etc. are all taxonomies — so they can be used to sort the reviews. There’s another taxonomy that doesn’t appear here called Ratings. I removed it from the menu because I only wanted 5 possible values for the rating system for 1-5 stars — I didn’t want people to add their own arbitrary ratings which wouldn’t work with the display once the front-end stuff is built. Additionally, when the plugin is activated, it automatically inserts 5 “terms” for the Ratings taxonomy — numeric values of 1 – 5. This way you will be able to sort by rating, but all of that is invisible to the user except when they are writing or viewing the review. Each of the taxonomies (except for Book Author and Genre) are optional, and can be enabled/disabled from the options page which I’ll go over in a bit. All the new taxonomies are off by default — this is a shot of the menu with all of them active — so you start out with a fairly simple system with only a few sub-pages that gets more complex as you enable more features.

The list

Book Review list

This should look familiar to anyone who’s used WordPress — it’s a standard post list, in this case featuring each review. This is an early version of this; I’m going to be adding custom columns so you’ll be able to see the various taxonomies (like Book Author, Genre, etc) for each book. What you won’t notice as much is the dashboard icon. Here, again, I’m using Genericons — the book is a character in the icon font — so I had to do some CSS magic to get that to display instead of an image icon. The future (MP6) WordPress dashboard doesn’t use icons at all, so that’s moot, but it actually made it easier to work with since I don’t have to create some rules and then create new rules to cancel out the first rules when the next version of WordPress rolls around. You’ll also notice that the author of the Shadow and Bone review is “reviewer”, which is a user I created to test out the new user roles that are added by this plugin as well, which I’ll also go into in a bit…

Add new

Add new book review

Here’s the Add New screen and, as you can see, there’s a lot of stuff. By default, WordPress loads all taxonomies on the right side — they can be moved around by dragging them, but that forces the user to do that and, otherwise, makes a huge list on one side that ends up lopsided. I tried to counter this a bit by moving some of these to the middle and then, using some admin css, resized the boxes so I could fit more in a smaller space. It’s not a perfect system, it’s not perfectly responsive, but it’s a start. I tried grouping the taxonomies by things that would typically go together, so author, illustrator and series are all together under the review, while genre and subject live together in the right column. It’s still crowded, but again, this gets much simpler if you have fewer options enabled.

Options

Options

This is the options page where you can turn on/off any of the settings. With the exception of Stock, each of these corresponds to a taxonomy that doesn’t get called if the option is disabled. For Awards, the Upload Award Image section does not appear if the Awards option is disabled and if both Awards and Stock are disabled, that Additional Information box disappears.

User Roles

User Roles

Finally, the user roles. User Roles are my new favorite thing to play with. I just got done building a different plugin for the Open Classroom that added user roles to control a different post type, and thought that I could do that here as well. In the Book Reviews plugin, there are two new user roles, Librarian and Book Reviewer.

Book Reviewer is similar to an Author in WordPress — they can publish their own reviews, but they can’t edit others’. Additionally (and different than the Author role), they can use all the taxonomies that are used by the plugin (so they can add the author, genre, awards, etc). They have also been given the ability to create and publish WordPress posts, but they can’t edit other people’s posts.

Librarian is basically the Book Review admin — they can edit other people’s reviews and publish their own, but as far as the rest of the WordPress admin, they don’t have any capabilities higher than what the Reviewers can do.

All the Book Review posting and publishing capabilities have also been mapped to the existing WordPress user roles corresponding to their existing capabilities otherwise, with the exception of the Author role (which normally can’t publish posts) who can, like the Book Reviewer, actually publish book reviews, rather than submit them for someone else to review before publishing.

So when’s it going to be ready?

Hopefully, I’ll be finishing this up this week and then I’ll post it to the WordPress.org plugins repository as a free plugin. Yes, this is a lot of work to put up for free, but honestly, I have more than enough on my plate right now to want to deal with figuring out a way to monetize it. What will be coming soon will be shortcodes to display reviews and tweaking the columns in the Book Reviews list as well as preparing (and testing) the language files so it can be localized into other languages. If you’re interested in testing it before I make it public, give me a holler either on Twitter or on the contact form on my about page and I’ll send you a copy. Currently it’s being hosted on a private Git repository I set up not long before WordCamp SF.

Right now!

Update

New post columns!