Allowing specific users to only add posts using certain custom taxomy terms

First hook the save_post action: http://codex.wordpress.org/Plugin_API/Action_Reference/save_post Then check capabilities: You have docs on that right? Then get_the_terms for the $post_id provided by save_post and the taxonomy you want to check. http://codex.wordpress.org/Function_Reference/get_the_terms Then if they are using a term (see note below) they are not allowed to use either stop/delete the post, set a warning, or … Read more

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

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

How can I hide a category from Contributors in the edit/add new post screen?

Working Example in Oct 2020, Working answer, I went to different answers none of them works now in new WordPress. function hide_categories_for_specific_user( $exclusions, $args ){ if ( ((defined( ‘REST_REQUEST’ ) && REST_REQUEST) or $GLOBALS[‘pagenow’] === ‘edit.php’ ) && !current_user_can( ‘manage_options’ ) ) { // IDs of terms to be excluded $exclude_array = array(“12″,”16″,”17”); // CHANGE … Read more

Restrict admin access to certain pages for certain users

This code seems to work well for me (in functions.php): $user_id = get_current_user_id(); if ($user_id == 2) { add_filter( ‘parse_query’, ‘exclude_pages_from_admin’ ); } function exclude_pages_from_admin($query) { global $pagenow,$post_type; if (is_admin() && $pagenow==’edit.php’ && $post_type ==’page’) { $query->query_vars[‘post__not_in’] = array(‘123′,’234′,’345’); } }

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