Capibilities of CPT WordPress

Adding custom capabilities should use the ‘admin_init’ hook. Your function can look like this: function add_bounty_product_caps() { $role = get_role( ‘mmv_multi_vendor’ ); $role->add_cap( ‘edit_crea_resi’ ); $role->add_cap( ‘edit_crea_resis’ ); $role->add_cap( ‘edit_others_crea_resis’ ); $role->add_cap( ‘publish_crea_resis’ ); $role->add_cap( ‘read_crea_resi’ ); $role->add_cap( ‘read_private_crea_resis’ ); $role->add_cap( ‘delete_crea_resi’ ); $role->add_cap( ‘edit_published_crea_resis’ ); $role->add_cap( ‘delete_published_crea_resis’ ); $role->add_cap( ‘edit_crea_spedizioni’ ); $role->add_cap( ‘edit_crea_spedizionis’ ); … Read more

Custom site role cannot access Appearance menu

WP Custom Site Roles appear to be a bit ‘flaky’ at best but this particular solution worked for me (created a custom plugin for it). $result = add_role( ‘org_site_owner’, __( ‘Site Owner’ ), array( ‘activate_plugins’ => false, ‘create_users’ => true, ‘customize’ => true, ‘delete_others_pages’ => true, ‘delete_others_posts’ => true, ‘delete_pages’ => true, ‘delete_plugins’ => false, … Read more

In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?

It sounds like you want to remove the following permissions from the ‘liaison’ role: create_users delete_users edit_users promote_users remove_users Keep “list_users” so they can see the list, but not edit anything. The easiest way to remove these permissions is to use a Role Editor plugin. Several are available; you’ll select the ‘liaison’ role, and then … Read more

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.

How can I create multiple different admin roles with their own capabilities

Yes it’s very easy. You’ll want to use the add_role() function to add your custom roles – https://codex.wordpress.org/Function_Reference/add_role Then you can use add_cap to add custom capabilities – https://codex.wordpress.org/Function_Reference/add_cap One important thing to mention is that both add_role and add_cap are saved to the database so they only need to run 1x so it’s good … Read more

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