If post by specific role different css to everyone

You can update the post classes depending on user role to include an additional selector which add your custom styling i.e function add_contributor_class_to_single_post( $classes ) { if ( is_single() ) { $post_id = get_queried_object_id(); $author_ID = get_post_field( ‘post_author’, $post_id ); $author_data = get_userdata( $author_ID ); if (in_array( ‘contributor’, $author_data->roles)) { // add post class array_push( … Read more

User Roles Not Sticking

You might want to use WP_User::set_role( ‘contributor’ ) instead. It unsets all current roles and sets the new one (the argument) too. So the above would be if ($count_posts >= $postlimit) { $current_user->set_role( ‘contributor’ ); }

WordPress missing user roles on local dev machine. Live site works fine

I just exported the live database, replaced all occurences of the live siteurl with the local one, and imported on my dev machine. Finding/replacing with a text editor breaks serialized data; you must change values with MySQL queries in phpmyadmin: UPDATE wp_options SET option_value = replace(option_value, ‘http://www.olddomain.com/’, ‘http://www.newdomain.com/’) WHERE option_name=”home” OR option_name=”siteurl”; UPDATE wp_posts SET … Read more

Advanced Custom Fields/User Role Editor – how to hide ACF for certain users?

The admin_menu action will hide the ACF menu, in this example for not-admins. And admin_head will block the access if the URL is accessed directly. E.g.: http://example.com/wp-admin/edit.php?post_type=acf and http://example.com/wp-admin/edit.php?post_type=acf&page=acf-settings add_action( ‘admin_menu’, ‘wpse_59032_remove_acf_menu’, 9999 ); add_action( ‘admin_head-edit.php’, ‘wpse_59032_block_acf_screens’ ); add_action( ‘admin_head-custom-fields_page_acf-settings’, ‘wpse_59032_block_acf_screens’ ); function wpse_59032_remove_acf_menu() { /* if not our allowed users, hide menu */ if … Read more

Why are authors allowed to approve comments on their posts? How to revoke privilege?

The ability to set comment status is tied to the “edit_comment” capability, which is a meta-capability in WordPress. It maps to the “edit_post” capability, which is another meta-capability that varies depending on whether a post is published or not. In the end, if a post is published, then edit_comment ends up mapping to “edit_published_posts” for … Read more

Custom function for specific user role

The core has functions like current_user_can to check for an capability of a role or check the role directly. The follow example extend your source for this check so that the function not (!) run, if the current user haven’t the rights, the capability of his role. add_filter(‘request’, function( $vars ) { // Check the … Read more

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