Tag Info

New answers tagged

1

I've found it. /*** Adding extra field to get the the user who creates the another user during ADD NEW USER ***/ function custom_user_profile_fields($user){ if(is_object($user)) $created_by = esc_attr( get_the_author_meta( 'created_by', $user->ID ) ); else $created_by = null; ?> <h3>Extra profile ...


0

First add capabilities to the roles like this add_action( 'after_setup_theme', 'add_caps_to_custom_roles' ); function add_caps_to_custom_roles() { $caps = array( 'read_cpt', 'edit_cpt', 'edit_others_cpt', ); $roles = array( get_role( 'third_party' ), get_role( 'data_entry_operator' ), ); foreach ($roles as $role) { foreach ...


0

This is what I just used, maybe there was a problem in past versions of WordPress or your theme. function allow_contrib_upload() { // get the role $contrib = get_role( 'contributor' ); // add the upload capability $contrib->add_cap( 'upload_files' ); } add_action( 'admin_init', 'allow_contrib_upload', 11 );


3

Firstly, you need to add the following capabilities to the Doctor and Receptionist role: list_users edit_users create_users delete_users Now we can get to work with controlling which users they can create/edite/delete. Let's start with a "helper" function that will return which roles a user is allowed to edit: /** * Helper function get getting roles ...


0

From WordPress Codex: Changing the capabilities of a role or user is persistent, meaning the added capability will stay in effect until explicitly revoked. You might want to do something like: $roleObject = get_role( 'editor' ); if ($roleObject->has_cap( 'edit_theme_options' ) ) { $roleObject->remove_cap( 'edit_theme_options' ); }


2

OK, so your first problem is that $current_user->roles is an array and not a string, so your condition won't be true ;) My another concern would be the hook you're using. Some plugins may use it for other purposes, and killing the script can be harmful. And... there is much better hook for this ;) First solution: using login_redirect hook function ...


1

This is right. You can use Wordpress in exactly the same way as you were using your OLD CMS. Wordpress is being used by Top newspapers / magazines and websites and they've editors / authors and bloggers and ofcourse they have groups & roles. CNN, Mashabale, TechCrunch, etc are all based on Wordpress. There are Free and Premium both type of plugins to ...


1

Don't remove the capability - this will make all editors unable to edit all posts. Instead, use a filter to conditionally determine if the post can be edited: function wpse_187738_map_meta_cap( $caps, $cap, $user_ID, $args ) { if ( $cap === 'edit_post' && $args && ! current_user_can( 'manage_options' ) /** Only proceed for ...


1

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' => ...


1

This is treading very close to being off-topic as it asks specifically about a particular plugin, but the answer is quite generic: You can remove the capabilities you don't need. function remove_cap_wpse_186316(){ remove_cap( 'yourwoorole', 'yourwoocap' ); remove_cap( 'yourwoorole', 'yourwoocap1' ); } add_action( 'admin_init', ...


0

I found an answer. It is because the WooCommerce plugin which prevents users without edit_posts capability to display dashboard. Well, I think they should let you know that they are making this kind of change in WordPress default settings. Because you are not able to turn it off in WooCommerce settings.


2

Hint The changes on roles and no layout-topics should not a part of a Theme, is much more a topic for a plugin. maybe you think about this topic on point like maintenance, switch of theme and hooks for activation - easier on plugins. For your problem You must add the roles new capabilities for your custom post type and remove the capabilities for type ...


1

Add the capabilities to the role. Replace 'cpt' with the name of your custom post type: $role = get_role( 'contributor' ); $role->add_cap( 'delete_published_cpt' ); $role->add_cap( 'delete_others_cpt' ); $role->add_cap( 'delete_cpt' ); $role->add_cap( 'edit_others_cpt' ); $role->add_cap( 'edit_published_cpt' ); $role->add_cap( 'edit_cpt' ...


0

You can write a small custom plugin, that run on the activation hook. A example, write from scratch function fb_add_roles( $user_id ) { foreach( get_blog_list( 0, 'all' ) as $key => $blog ) { if ( is_user_member_of_blog( $user_id, $blog[ 'blog_id' ] ) ) continue; switch_to_blog( $blog[ 'blog_id' ] ); $role = ...



Top 50 recent answers are included