Why are all roles assigned to a user when using wp_insert_user()?

You need to update the user straight after they have been created. So yes, by default they get all then you update. wp_update_user( array (‘ID’ => $user_id, ‘role’ => ‘user_role_here’) ); The above should fix this issue. Obviously changing the $user_id to your style of ID and also user_role_here to editor or alike. Thanks, Tom

dynamic home page according to role user

$query->is_home() is not, well, ‘home’. $query->is_home() checks of you are viewing the blog/posts page. It’s an artifact from when the home page of WordPress sites was invariably the blog. You want to change that to $query->is_front_page(), which checks if the front page of the website is a page, and if you are on that page.

Streamlining what roles and users see

There are a couple of options here. One, which I’ve found the easiest, is to move content you want to protect into custom post types. From there, you create specific permissions (capabilities) for each CPT, and WP will automatically only show the content that the current user has permission to edit in the back end. … Read more