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' );
}
Related Posts:
- Capability to edit own posts and not others
- Modify custom Users Manage page
- Creating user relationships
- Ability to only view (not edit) other user’s personal profile information
- I want to submit multiple users if checkbox is checked
- Custom Role with Own Page Edit Capability
- How to stop displaying the Id without losing the functionality
- how to make a custom field readonly or disabled by user role?
- Allow multisite admins only to create users with one specific user role?
- Hide content and functions from specific user roles
- Custom roles and capabilities media not work right
- Show comments based on user role in front end
- Disallow “contributors” to edit their own posts once they’ve been set to “Pending Review”
- Change the functionality of wordpress users module in admin
- What capability is required to view posts, scheduled in the future, by someone else?
- Security Issues with custom user role or changing core role capabilities?
- Plugin SVN & update API – how are plugins identified?
- How to use more than 256MB of memory in the admin?
- Custom Search Query
- How to get current_cat in navbar, in single post
- Removing fields from the Media Uploader/Gallery
- When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?
- wordpress custom walker for thumbnails with custom menu
- Selecting An image from the Media LIbrary on the frontend
- WordPress audio player has two different styles
- How wp_ajax_nopriv since WordPress 3.1
- WordPress 3.1 removing ‘category’ from the slug
- Why does WordPress 3.0.4 keep deleting the contents of the .htaccess file?
- Set user loggin status?
- Intercept invalid email during lost_password
- Only append custom classes to nav menu items
- redirect product-category to a custom page
- custom headers for static home page and posts page
- WP-Admin gives 403 Forbidden after login on CentOS 7
- Custom Taxonomy Archive not displaying entries
- Multiple Blogs on one site. Best Practise
- Limiting allowed html elements/strip harmful scripts from editor
- Customizing default Mediaelement player
- Custom members area (interface/design) in WordPress, is it possible and how?
- Override database config for WordPress multiblog
- Password protected photo galleries
- How do I fix unexpected redirection of visitors after enabling multisite on WP3?
- Add more then one site logo – custom-logo theme support
- How to get “string” away – replaced with “nothing” [closed]
- Can not sanitize select control in customize api
- Putting tag outside tag on generated Menu
- Multiple RSS feeds scroller in one sidebar
- How to encode author ID in the author permalink
- Remove add news page and posts from menu
- Custom Status of Custom Post type need to EXCLUDE from Taxonomy pages
- redirect post id to post full url
- Silo Structure; Will links from home page to a Sub-category or Post undermine silo seo advantage? [closed]
- Manage multiple domains from one backend
- custom default avatar showing broken link
- How can I create a permalink with two categories, with the order based on the parent category?
- Customize option – add two image uploader under same section
- Moving wp-content folder
- Modify the display Text of number of comments
- Toggle custom fields?
- Creating a shortcode by pulling in a custom field from a plugin
- How to add span on WordPress Title for first and third word
- Edit specific text on a static page
- Customise the Category Widget
- Showing Meta Box via Jquery Checkbox
- custom user meta query
- problem saving/ retrieving custom meta with wp alchemy metabox
- Problem with custom function from jQuery slider tutorial
- How to style bootstrap container in WordPress?
- Problems with setting up a subdomain to serve images and scripts
- Change login cookie expiration time?
- Disable “-mp4-image” screenshots from appearing in Media?
- wordpress custom posts page not showing
- Wrap WordPress Login Form in custom Div
- Automatically reject a comment if website field contains anything
- Post filter with multiple checkbox taxonomy terms
- Replace publish date in blog module with custom field
- generate a static copy of the website footer html
- Multi-site customization
- Creating WordPress staging environment software
- How to add H1 Tag on Homepage?
- Show different pages on site depending on user choice
- Is there a way to limit multi upload in media upload box?
- Use another theme template in my theme
- Display popular posts by how many hits it got within 30 days of publishing
- Pulling posts into static site (wordpress as subdirectory)
- Call a duplicate registration form with other url
- How to support extra color options for shortcodes?
- WP Customizer – what types of fields is it capable of supporting?
- How to make my wordpress site responds for 2 domains
- User registration add user ID?
- Pass query param to custom page
- How to answer, and we aren’t using WordPress to manage your site? [closed]
- responsive screen not working [closed]
- Is there a way to have information on one page automatically feed into another? [closed]
- Custom Post want button to add image and save in Postmeta
- Save And Display Mp3 Audio files on WooCommerce product page with Dokan
- Advice how to connect custom database with WordPress, change data in WordPress and finaly use this data
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- Is it possible assign a secondary existing role to already existing one?
- Set custom banner image size with wp_customize