user roles and permissions

Here we will discuss about the wordpress general help and support.
  • Ads

user roles and permissions

Postby joselin » Thu Aug 05, 2010 12:31 am

I have looked around for info but im having a hard time understanding things to clear...

specifically i would like to assign certain registered users of my wp site the ability to simply approve and disapprove comments, i dont want to give the ability to post, or delete anything else because the people i want to give this comment moderation to could coincidently break stuff.. and i want to minimize this. because i break stuff enough as it is...

is there a relatively easy way to do this?
joselin
Jr. Member
Jr. Member
 
Posts: 208
Joined: Thu Jul 29, 2010 6:07 am

Re: user roles and permissions

Postby johnys » Thu Aug 05, 2010 12:32 am

Create a new role, copy the capabilities of the existing role(subscriber for example), then give this new role an extra capability "moderate_comments". Then assign the role to users you want to give moderation powers to.

The following plugin allows you to add or remove roles and capabilities.
http://wordpress.org/extend/plugins/members/

Other plugins are available, that's just my personal preference in terms of role management plugins.

If you want help, get stuck, just post back.. ;)
johnys
Jr. Member
Jr. Member
 
Posts: 144
Joined: Fri Jul 30, 2010 12:31 am

Re: user roles and permissions

Postby joselin » Thu Aug 05, 2010 12:32 am

thanks t3,
i downloaded this but i have to say i dont see how to use it, i dont now how to create roles or where to put "moderate_comments" ....
any not so hard ways of helping me on this one?
pretty simple,. i want to create a few accounts that can simply approve disapprove and delete comments.. from any page.. that way nothing can be broken
thank you
joselin
Jr. Member
Jr. Member
 
Posts: 208
Joined: Thu Jul 29, 2010 6:07 am

Re: user roles and permissions

Postby johnys » Thu Aug 05, 2010 12:33 am

If you can tell me what the role of the users who have this special ability to moderate comments currently is i'll write the code to add the new role for you, all you'd then have to do is add the code (once, when the role is created it exists until it's removed).

Then assign that role to the relevant users.

Easy, i just need to know what the current role for these users is (so i know which role to base the capabilities on).

Alternatively, if you prefer the plugin approach, i can run over the procedure for doing it in the members plugin.
johnys
Jr. Member
Jr. Member
 
Posts: 144
Joined: Fri Jul 30, 2010 12:31 am

Re: user roles and permissions

Postby joselin » Thu Aug 05, 2010 12:33 am

right now i have defualt roles... um do i have to create a new role? i am in testing stages so these accounts do not exist right now.. man im sorry for the lack of info i can provide
joselin
Jr. Member
Jr. Member
 
Posts: 208
Joined: Thu Jul 29, 2010 6:07 am

Re: user roles and permissions

Postby johnys » Thu Aug 05, 2010 12:33 am

What role are you intending to give these particular users?

It's possible to create custom roles that contain existing capabilities. For example, i could take the subscriber role, copy the capabilities, add one new capability, such as moderate_comments, and call it "Comment Moderator", or anything you like.
johnys
Jr. Member
Jr. Member
 
Posts: 144
Joined: Fri Jul 30, 2010 12:31 am

Re: user roles and permissions

Postby joselin » Thu Aug 05, 2010 12:33 am

that sounds like what i would want. to create a role with an added ability to moderate comments. i believe thats perfect
joselin
Jr. Member
Jr. Member
 
Posts: 208
Joined: Thu Jul 29, 2010 6:07 am

Re: user roles and permissions

Postby johnys » Thu Aug 05, 2010 12:34 am

So which would you prefer, a code example, or a set of instructions on how to do it using the plugin?

:)
johnys
Jr. Member
Jr. Member
 
Posts: 144
Joined: Fri Jul 30, 2010 12:31 am

Re: user roles and permissions

Postby joselin » Thu Aug 05, 2010 12:34 am

i think id like to go with the code example, i would like to minimize plugin use. and id like to learn my way around some little coding things . so the code example please :-D
thank you
joselin
Jr. Member
Jr. Member
 
Posts: 208
Joined: Thu Jul 29, 2010 6:07 am

Re: user roles and permissions

Postby johnys » Thu Aug 05, 2010 12:34 am

Just noticed i never came back to you with an example, i do apologise (thread tracking is a pita on these forums).

Here's an example for creating a role based on the editor role, with moderate_comments added as additional capability.

// Will work from the theme's functions.php file, and only needs to run once, remove the code after loading a page with this code in (it doesn't need to keep running)

$_the_roles = new WP_Roles();
$_copy_from = 'editor';
$_extra_caps = array(
'moderate_comments' => 1
// Each capability you want to grant the new role should follow the same format as above
// Key = Capability
// Value = 1 (grant, 0 would be deny but we don't typically add non-granted caps to roles)
);
$_caps_for_role = array_merge( $_extra_caps, (array)$_the_roles->roles[$_copy_from]['capabilities'] );

add_role('comment_moderator', 'Comment Moderator', $_caps_for_role );
You can change the string editor to the role you want to copy from.

Sorry for the delay in responding.. ;)
johnys
Jr. Member
Jr. Member
 
Posts: 144
Joined: Fri Jul 30, 2010 12:31 am

Re: user roles and permissions

Postby joselin » Thu Aug 05, 2010 12:35 am

:-D no worries, thank for the help!
joselin
Jr. Member
Jr. Member
 
Posts: 208
Joined: Thu Jul 29, 2010 6:07 am

Re: user roles and permissions

Postby johnys » Thu Aug 05, 2010 12:35 am

You're welcome, let me know if you have any problems.. :)
johnys
Jr. Member
Jr. Member
 
Posts: 144
Joined: Fri Jul 30, 2010 12:31 am

  • Ads

Return to Wordpress General Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron