Allowing a CPT post to be edited by a single user role

Add code – your current active theme’s functions.php file or in a custom plugin: // Step 1: Create a New Role Based on Subscriber function create_custom_role() { // Check if the role doesn’t already exist if (!get_role(‘username-role’)) { // Get the capabilities of the Subscriber role $subscriber_role = get_role(‘subscriber’); $capabilities = $subscriber_role->capabilities; // Create a … Read more

How can I add the User Menu for Authors (role)?

How do I make this (and the pages) appear for authors, now that they actually have the relevant capabilities? They don’t have the needed capabilities, just because a role can add/edit/remove users does not mean they can list_users. Similarly there are other capabilities such as role promotion etc, here’s the code for administrators, e.g. this … Read more

WordPress User Role Permissions For Custom Post Type

Your function looks generally correct, but there are a couple of small mistakes that need to be addressed. Here’s a corrected version of your code: function control_dfwp($query) { $user = wp_get_current_user(); if (in_array(‘Registered for Portal’, $user->roles)) { $query->set(‘author’, $user->ID); // Use $user->ID instead of $current_user->ID } } add_action(‘pre_get_posts’, ‘control_dfwp’); Here are the corrections: Use $query … Read more

Hide ID for WordPress User Role Subscriber

You can use the body_class filter and the wp_get_current_user() function to add the current user’s role to the <body> element, and then hide your elements with that (untested): add_filter( ‘body_class’, static function ( $classes ) { $user = wp_get_current_user(); $roles = $user->roles; if ( ! is_array( $roles ) ) { $roles = array( ‘subscriber’ ); … Read more

techhipbettruvabetnorabahisbahis forumuedusedueduseduedusedueduseduedusedu