Limit User Role to Certain Posts

There are a variety of plugins out there for managing user role access. User Role Editor (URE) and Advanced Access Manager (AAM) are both good plugins I can recommend.URE is great for…editing roles. The problem with URE is that it doesn’t allow more narrowly scope restrictions…like to single posts. AAM is great at limiting individual posts and hiding admin menus. AAM however requires a LOT of setup if you have a lot of pages / a lot of roles and starts to become unpractical for highly restrictive page editing.

All that said, I ended up turning to good ol’ taxonomies.

First, setup your taxonomy for your posts. In this case I am targeting a “Departments” custom post type.

See jp_register_cpt and jb_register_taxonomy for info on these functions.

Second, setup your roles with URE. I’ll leave this to you, but I usually start with copying either the “Contributor” or the “Subscriber” default roles and going from there. Mine looks like this:

Third, Add a new admin taxonomy in the net taxonomy you just created. Make sure to give it the same slug as the user role ID, this is just for ease of use later and for reference. Example:

Forth, add this function to your PHP file.

All done! Now this user role should not be able to view or edit any posts that do not have this category.

Send Email on “Submit for Review”

When you have a contributor or some other role that can create posts but not publish them they need to “Submit for Review”. Well of course if the admin doesn’t know this is submitted then…they wont know it has been submitted. So let’s notify them!

You’ll notice I am only sending this email if the user role is ‘agency’ and the post type is a ‘tribe_event’ so that we are not spamming the admin with these.

Login with Email

Sometimes users just want to deal with remembering the email address and not a username.

Should work for both WordPress and Woocommerce accounts.

Insert WP Users by CSV

Sometimes we need to import many users into a site. While there are many ways this can be done a common one is through CSV. Here is the code for that.

This can be easily adapted for a DB query or xml file.