add_menu_page permissions – what am I doing wrong?

You want the admin_menu hook, rather than admin_init. Also, you shouldn’t use anonymous functions. Instead, use: function wpse51004_add_menu_page() { add_menu_page(‘Some Page’, ‘Some Page’, ‘manage_options’, ‘some-slug’, ‘wpse51004_some_page_callback’); }; add_action(‘admin_menu’, ‘wpse51004_add_menu_page’); function wpse51004_some_page_callback() { echo ‘Hello, world!’; }

How to assign specific users the capability to edit specific pages / posts / custom post types

I can suggest another method. First of all: grant full access to projects post type (Example). At the user profile add allowed posts’ id. Then use below filter to restrict access if post id isn’t allowed. function allow_user_to_edit_cpt_filter( $capauser, $capask, $param){ global $wpdb; $allowed_posts_id_for_current_user = array( ’29’, ’30’ ); // you need to get these … Read more

Add Custom User Capabilities Before or After the Custom User Role has Been Added?

There’s a reason why add_role() has the $capabilities as 3rd parameter. First some insights on what happens, when you use the function. It calls WP_Roles->add_role() – the class method The method then does a check if the role already exists. If yes, it aborts. The next step is, that it adds the role to WP_Roles->roles[] … Read more

Capabilities Vs User Meta

There is no one answer, because both have pros and cons depending on what you want to store and why. A (probably non-exhaustive) list of differences to consider for a choice: Capabilities are designed to check if a user can do something or not. user_can and current_user_can are there to help you to check user … Read more

Disallowing Users of a Custom Role from Deleting or Adding Administrators?

Hi @NetConstructor: I think this is what you need. Note that I didn’t include the full setup of your ‘website_owner’ role, just the addition of a new capability called ‘manage_administrators’. Also, I only attempted to remove the “Delete” link from any users that don’t have the ‘manage_administrators’ capability (which you’ll need to add to the … Read more

Allow roles below admin to add subscribers only

This first step to making this happen is add the capability to create_users to a given role. You do this be calling get_role, then using the add_cap method. This only needs to be done once. Here’s an example that does it on plugin activation. <?php register_activation_hook( __FILE__, ‘wpse42003_activation’ ); function wpse42003_activation() { foreach( array( ‘editor’, … Read more

How to assign multiple roles for capabilities array withini register_taxonomy function?

When assigning capabilities to ‘capabilities’ argument of register_taxonomy() you need to assign the capability and not the role! so use capabilities that only a specific role has eg: ‘capabilities’ => array ( ‘manage_terms’ => ‘manage_options’, //by default only admin ‘edit_terms’ => ‘manage_options’, ‘delete_terms’ => ‘manage_options’, ‘assign_terms’ => ‘edit_posts’ // means administrator’, ‘editor’, ‘author’, ‘contributor’ )

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