Tag Info

New answers tagged

0

You can write a small custom function, that loop about the network and add in each site of the network the new role. See the source below als example to add_role. If you like update or change a existing role, then switch from add_role to add_cap. function fb_change_role_network_wide( $role ) { global $wpdb; $args = $args = array( ...


0

$ids = get_users( array('role' => 'author' ,'fields' => 'ID') ); for($cntr=0; $cntr < count($ids); $cntr++){ if( pmpro_hasMembershipLevel($level_id, $ids[$cntr] ) !== true ){ unset($ids[$cntr]); } } $args = array( 'author' => implode(',', $ids), 'orderby' => 'date', 'order' => 'ASC', ...


0

from Codex function add_theme_caps(){ global $pagenow; if ( 'themes.php' == $pagenow && isset( $_GET['activated'] ) ){ // Test if theme is activated // Theme is activated // gets the author role $role = get_role( 'author' ); // This only works, because it accesses the class instance. // would allow the author to edit others' posts for ...


1

You can check for specific user role using following code - if (is_user_logged_in() && current_user_can('administrator')) {} The function current_user_can() takes role name as parameter. For more info - https://codex.wordpress.org/Function_Reference/current_user_can/


0

You can make WordPress query for a certain user role by using current_user_can("role_name"). Thanks to Mayeenul Islam for providing the solution!


1

How about remove_meta_box( $id, $page, $context );? https://codex.wordpress.org/Function_Reference/remove_meta_box This will remove the Publish meta box which contains the save button... function disable_save() { if( !current_user_can( 'edit_post' ) ) { // Or whatever check you need to make remove_meta_box( 'submitdiv', ...


1

Notice how it is singular? Comment, not comments? This capability is not designed to check if user can edit any arbitrary comment out there. It can only check if user can edit one specific comment and correct way to call it is current_user_can( 'edit_comment', $comment_id ). Unfortunately second argument is missing from current_user_can() function ...


0

I think, to debug this scenario, you should first try following to get all the capabilities for the current user and see whether edit_comment actually exists in it or not - $user_id = get_current_user_id(); $userdata = get_userdata( $user_id ); $allcaps = $userdata->allcaps; $output = print_r( $allcaps, true ); echo '<pre>' . $output . ...


0

try to use a new WP_Query, when you use get_posts you're using the main WP_Query this has hooks that other plugins can use to alter the query. something else i saw is that you're using include key which is not valid $my_query = new WP_Query( array( 'post__in' => array( 1633, 1634, 1635 ), 'post_status' => 'any', 'post_type' => ...


0

You can edit it directly in your DB, and it will be edited permanently for your website. Here is where WP keeps user roles SELECT * from blog_options WHERE option_name = 'blog_user_roles'


2

There is no tax_query parameter for the WP_User_Query class. Since you've tagged the question with user-meta I can only assume you store the ID (or even the term name itself?) of a particular shop-category term as a user meta entry. In this case you would need something like this: // The 'WP_User_Query' arguments array $args = array( 'role' ...


1

You can use wp_get_current_user() function to get current logged in user's role //Remove admin menu items if not admin function remove_admin_bar_links() { global $wp_admin_bar, $current_user; $user = wp_get_current_user(); if ( in_array( 'author', (array) $user->roles ) ) { $wp_admin_bar->remove_menu('updates'); // ...


0

You can use Advanced Access Manager for access control on pages but you need to set which pages give these control. You can also control the comment, read and more. Please check this may help you.


1

I got it to work as follows -- in mu-plugins directory, my superAdmin.php script looks like this: <?php function check_for_superAdmin($user_login, $user) { $current_user = get_userdatabylogin($user_login); if ( is_super_admin( $current_user->ID ) ) { // do these things } else { // do other things } } add_action( 'wp_login', ...


1

Make sure your level ids are 1, 2, and 3, etc. //For check level id 1. if(pmpro_hasMembershipLevel(1, $user->ID)) You can check for get membership level of any user from documentation. PMPro includes a built-in function allowing you to require membership or require a specific membership level.


-1

Your code is missing break and also your requirement is like below: If administrator, YesNoMaybe OR if member, NoMaybe OR if oldmember, Maybe. Finally code is look like Below: function smoelenboek_func(){ $users = get_users('orderby=nicename'); foreach ($users as $user) { switch ($user->roles[0]) { case 'administrator' : ...


0

You missed break statement This is how switch case works switch ($i) { case "apple": echo "i is apple"; break; case "bar": echo "i is bar"; break; case "cake": echo "i is cake"; break; }


0

You can display user posts using user's ID. This code might provide a quick sample on how to do it (I have not tested the code). $user_id = $_GET['author_id']; //The Query query_posts("author={$user_id}"); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); echo "<br>"; endwhile; else: echo "No Posts!"; ...



Top 50 recent answers are included