Modifying Roles

Covert Commissions

Email Marketing Master Course

Get Instant Access

If you need to change one or two capabilities, it's relatively easy to do so with a few lines of code in a plugin (see Chapter 9) or your theme functions (see Chapter 7). For example, if you want to allow any logged-in user to view your private posts and pages, you need to grant them two additional capabilities, as shown in Listing 10-6. This bit of code should go in your theme functions file or in a new plugin.

Listing 10-6. Modifying an existing role

// allow subscribers to view private posts and pages $PrivateRole = get_role('subscriber'); $PrivateRole -> add_cap('read_private_pages');

$PrivateRole -> add_cap('read_private_posts'); ?>

The first line fetches the existing subscriber role (as an object) and assigns to it a variable. In the next two lines, you add the capabilities to read private posts and pages to our variable. That's it! Any subscribers can now read your private content—and so can authors and contributors, whose roles include all the capabilities of subscribers. (Remember that editors and administrators already had these particular capabilities.)

Was this article helpful?

0 0
Email Marketing Tips And Tricks

Email Marketing Tips And Tricks

Running a business today involves a number of components that never existed in the past. While business owners have a much greater reach to find their consumer, they also face a great deal more competition. The businesses that are the most successful are able to think outside the box and take advantage of tools that can help to grow their business. Email marketing campaigns are one of those tools. When used correctly this can be a powerful way to grow your business.

Get My Free Ebook


Post a comment