troubleshooting Question

Adjusting Wordpress Plugin PHP

Avatar of Chris Andrews
Chris AndrewsFlag for United States of America asked on
PHPWordPress
4 Comments1 Solution340 ViewsLast Modified:
I would like to use the 'edit author slug' plugin from:

http://wordpress.org/extend/plugins/edit-author-slug/

As is, it only allows admins to edit the slug, but I want my contributors and authors to edit the slug as well.

The author of the plug in says this can be done easily... "I've included a file in the 'edit-author-slug/includes' folder named 'caps.php.' This file will give you a jumping off point to give other users the ability to edit their own slugs."

Well, perhaps it's easy, but not for me. The code in the file is posted below - I don't know how to adjust it to provide capabilities to contributors and authors.

Do you know how and can you show me?

Thanks,                Chris



<?php

/**
 * Edit Author Slug Capabilities
 *
 * @package Edit Author Slug
 * @subpackage Capabilities
 *
 * @author Brandon Allen
 */

/**
 * I originally started this file to add a custom capability for
 * later use within the plugin. During development I decided it
 * wasn't safe to rely, solely, on a custom cap. However, it
 * would be beneficial to others looking, for example, to allow
 * subscribers to edit their own slugs. So rather than remove
 * all traces of what almost happened, I've left this file to
 * give others a starting point.
 */

/**
 * Adds capabilities to WordPress user roles.
 *
 * This is called on plugin activation.
 *
 * @since 0.7.0
 *
 * @uses get_role() To get the administrator role
 * @uses WP_Role::add_cap() To add various capabilities
 * @uses do_action() Calls 'ba_eas_add_caps'
 */
function ba_eas_add_caps() {
	// Add cap to admin role
	if ( $admin =& get_role( 'administrator' ) )
		$admin->add_cap( 'edit_author_slug' );

	do_action( 'ba_eas_add_caps' );
}
add_action( 'ba_eas_activation', 'ba_eas_add_caps' );

/**
 * Removes capabilities from WordPress user roles.
 *
 * This is called on plugin deactivation.
 *
 * @since 0.7.0
 *
 * @uses get_role() To get the administrator role
 * @uses WP_Role::remove_cap() To remove various capabilities
 * @uses do_action() Calls 'ba_eas_remove_caps'
 */
function ba_eas_remove_caps() {
	// Add cap to admin role
	if ( $admin =& get_role( 'administrator' ) )
		$admin->remove_cap( 'edit_author_slug' );

	do_action( 'ba_eas_remove_caps' );
}
add_action( 'ba_eas_deactivation', 'ba_eas_remove_caps' );

?>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros