Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have added a custom user role of super_poster, basically they make 20 posts and once they hit $postlimit get auto-moved back down to contributer level, the moving down and post counting works ok, my problem is that the wp system adds the user into "none" instead of into contributer role

if ($count_posts >= $postlimit) {
    $current_user->remove_role( 'super_poster' );
    $current_user->add_role( 'contributer' );

  }

contributer is set for new user default on sign-up, so the situation i have is in wp-admin user edit page i can see the newly moved (into contributer from super poster) has still got "additional capabilities of contributer" however user role dropdown says --No role for this site --

wp-admin users page shows the super_poster as in user group "none"

what gives?

share|improve this question
    
please try to give your best on phrasing your Q. It's extremly hard to understand what you're trying to ask. So far i understood that you wait until an author has 20 posts and then remove the contributer role from him and add the role of super_poster. I don't get around what happens then. Further more i don't understand your intention. I also don't know which capabilites you assigned to the super poster role and else. –  kaiser Apr 8 '11 at 14:00

3 Answers 3

up vote 1 down vote accepted

You might want to use WP_User::set_role( 'contributor' ) instead. It unsets all current roles and sets the new one (the argument) too.

So the above would be

if ($count_posts >= $postlimit) {
  $current_user->set_role( 'contributor' );
}
share|improve this answer

"contributor" is spelled with an O, perhaps you've just misspelled it?

share|improve this answer
    
LOL, I'll bet that's what the problem was! –  John P Bloch Apr 19 '11 at 18:04
    
Well i'l be jiggered! a typo...lol –  MartinJJ Apr 19 '11 at 18:29
    
Spelling always count!! –  Chris_O Apr 22 '11 at 7:42

sorry for my late reply, work and family life took control, regarding the issue i had, i tried John P Bloch suggestion and it resolved to being exactly the same: user role = None and No Role For This Site, i did quite a lot of researching via codex and couldnt realy come up with much, it dawned on me that im using a theme that sets user role as contributer on sign-up by default, so i tried the little block below and it does exactly what i need which is when user role is changed from custom role to Contributer, shows them in wp user panel as being a contributer rather than having no role.

//$current_user->set_role( 'contributer' );
$current_user->set_role(get_option('default_role'));

Dont know if its truly semantic from a WP way of doing this but it seems to be working the way i want it to do.

Regards Martin

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.