Skip to content

An example of using Auth0 to control subscriber access to WordPress Posts by Category.

License

Notifications You must be signed in to change notification settings

axyl/auth0-wordpress-categories

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Using Auth0 with WordPress

How to filter WordPress posts by category for subscribers (readers, not authors) using Auth0.

Tags: auth0, wordpress, auth0-plugin

Requirements

Setup

My sample was designed to work with a custom theme in WordPress, rather than as a plugin. (That should be changed...)

How you setup your user's details in Auth0 is up to you, but for a quick demo, I modified the app_metadata for the users I was testing with, to add blogCategories with slugs that they were permitted to view.

  • Install WordPress.
  • Create some Categories, with slugs, including free and paid (if you want to use my sample)
  • Setup an Auth0 account.
  • Create a new client in your Auth0 Applications area.
    • I created my Auth0 Client manually as my WordPress site was only available locally.
  • Set up your WordPress Child Theme.
    • The functions.php file from here should be placed into your Child Theme's directory.
  • Switch to that theme within WordPress.
  • Install the Auth0 Login plugin for WordPress.
    • Setup your Auth0 settings in WordPress Admin.
    • Note that if you do the automatic setup, then the Auth0 plugin tries to make a new client.
  • Log into the Blog with a new Auth0 based account, whether database or OAuth based.
    • Any posts that are not included in the paid category will be invisible to you.
  • Find the User in the Auth0 Users screen and modify their app_metadata to include...
{
  "blogCategories": [
    "paid"
  ]
}
  • You may will need to logout and login again on the blog to have Auth0 fetch that meta data (I think)
  • You should now be able to see the additional posts that were blocked before.

About

An example of using Auth0 to control subscriber access to WordPress Posts by Category.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages