Locking Down WordPress Application Password Permissions / Capabilities
Locking Down WordPress Application Password Permissions / Capabilities
Locking Down WordPress Application Password Permissions / Capabilities
As alternative to a cron job, you may use a “just in time” removal of the role. i.e. when an user logs in, you can check if it has the role(s) you want to expire, check current date with download date and update the user accordingly. This assumes that you are able to get the … Read more
Please try this code instead- add_filter( ‘body_class’, ‘wpse_268176_body_class’ ); function wpse_268176_body_class( $classes ) { $user = wp_get_current_user(); if ( in_array( ‘subscriber’, $user->roles ) ) { $classes[] = ‘class-name’; // your custom class name } return $classes; } Place this in your active theme’s functions.php file. [Thanks Dave Romsey for your suggestion.]
#Update: Wow, I feel like such a buffoon… haha. WP_Role::has_cap I can’t (role) my eyes hard enough. $caps = array( ‘cap_1’, ‘cap_2’, ‘cap_3’ ); $roles = array( ‘administrator’, ‘editor’ ); foreach( $roles as $role ) { if( $role_object = get_role( $role ) ) { foreach( $caps as $cap ) { if( !$role_object->has_cap( $cap ) ) … Read more
there is a lot of discussion about this in wishlisMembers support forum but the developers over there ignore it. Any way try this: // get the current user level from WP more important is global $user. $user = wp_get_current_user(); // Get user levels from WishlistMembers $levels = WLMAPI::GetUserLevels($user->ID); //then run the check for the level … Read more
Simple all you need to do is edit this part of the code : function editable_roles( $roles ){ if( isset( $roles[‘administrator’] ) && !current_user_can(‘administrator’) ){ unset( $roles[‘administrator’]); } return $roles; } and change it to function editable_roles( $roles ){ //don’t change anything if current user is admin if (current_user_can(‘administrator’)) { return; }else{ if( isset( $roles[‘administrator’] … Read more
You must set to true for them to take affect. If you do not specify true they all default to NULL which in turn basically makes them false. So to create a roll that allows pages only: add_role(‘page_editor’, ‘Page Editor’, array( ‘read’ => true, ‘edit_others_pages’ => true, ‘edit_pages’ => true, ‘edit_published_pages’ => true, ‘delete_pages’ => … Read more
I think your function nesting is slightly muddled; call ucfirst after translating, like so: esc_html( ucfirst( translate_user_role( $user->roles[0] ) ) ); My bad, completely skipped a beat there. You should instead be using: translate_user_role( $GLOBALS[‘wp_roles’]->role_names[ $user->roles[0] ] ); It’s unreliable to assume that all role display names are simply ucfirst( $role key ). If that … Read more
Interesting functionality, you will need something that does this: Will need to use the hook set_user_role to detect when user role change Then will need to query all posts from that user Then use wp_update_post to change the post status
I assume you need a foreach loop and echo each roles name separately. Here’s how to do it: global $wp_roles; $user_role = get_userdata($user->ID)->roles; // Check if there is any role for this user if( $user_role ) { foreach ( $user_role as $key => $role ) { echo $wp_roles->role_names[ $role ]; // Add a seperator except … Read more