Prevent author role from editing all posts in custom post type?

You should declare your desired capabilities when you are registering the post type. Justin’s article here is a good one for custom post types: http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress When you are registering your custom post type, you can set this to be standard capabilities for posts, eg: ‘capability_type’ => ‘post’, or to be standard capabilities for pages, eg. … Read more

WP_User->add_role producing unexpected results

This would be best as a comment, but no reputation 🙂 In the codex they say “If you are defining a custom role, and adding capabilities to the role using add_role(), be aware that modifying the capabilities array and re-executing add_role() will not necessarily update the role with the new capabilities list. The add_role() function … Read more

Get (echo) all role names assigned to user

I assume you need a foreach loop and echo each roles name separately. Here’s how to do it: global $wp_roles; $user_role = get_userdata($user->ID)->roles; // Check if there is any role for this user if( $user_role ) { foreach ( $user_role as $key => $role ) { echo $wp_roles->role_names[ $role ]; // Add a seperator except … Read more

Change the user role after x days

Here is an idea that you can implement. I think it will work just fine. Save the expiration time in user meta. Say the meta name is change_role. What you save in the meta is unix time. If you want to change them back in 14 days. Set the meta value to time() + 60 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)