Display user meta by different user role

In your author.php file, get the user metadata via get_user_meta(), then do an if statement of $user->roles == ‘rivenditore’, display the meta data as you desire, and then do an elseif $user->roles == ‘installatori’ statement with what you wish to display for users on other roles. EDIT: Code example as requested: // get author data … Read more

Adding an additional role to an Administrator

use the profile_update hook and in the hooked function, run this check to make sure that it’s adding the previous data to the users profile on update too. if ( $update ){ do_action(‘profile_update’, $user_id, $old_user_data); }else{ do_action(‘user_register’, $user_id); } return $user_id; This answer can help you understand it more: WordPress edit_user_profile_update update secondary role

Disable plugin per user role

You should use the wc_payment_discounts_apply_discount filter. Try something like the following: function remove_privato_discounts() { global $woocommerce; get_currentuserinfo(); global $current_user; if ($current_user->ID) { $user_roles = $current_user->roles; $user_role = array_shift($user_roles); if ( $user_role !== ‘b2b’) { $discount = 0; $woocommerce->cart->discount_total = $discount; return true; // Do not apply discount to privato } } return false; } add_filter( … Read more

How to allow users to view pending posts of a specific custom post type?

You need to make a custom query to display these pending posts. Here is an example using get_posts(): $args = array( ‘post_type’ => ‘post_type_name’, ‘post_status’ => ‘pending’, // -1 shows all ‘posts_per_page’ => -1, ); $pending_posts = get_posts( $args ); foreach( $pending_posts as $pending_post ) { // post object properties $id = $pending_post->ID; $title = … Read more

Assign second role to user

If you first fetch a WP_User object with get_userdata(), you should then be able to add your additional role with the add_role() method, like so: $user = get_userdata($user_id); $user->add_role(‘partner’);

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