New answers tagged

0

If you don't want to install a plugin to just to do this one task, you can call the WordPress function directly to rebuild the roles and their capabilities. if ( !function_exists( 'populate_roles' ) ) { require_once( ABSPATH . 'wp-admin/includes/schema.php' ); } populate_roles();


1

You just need to move the capability check "inwards": function wpse_230369_quote_of_the_day( $user ) { $quote = esc_attr( get_option( 'quote_of_the_day' ) ); ?> <div class="visible-only-for-admin"> <h3>Quote of the Day Input Field</h3> <table class="form-table" > <tr> <th><label ...


0

The most obvious approach to this would be to first create a special user role for your students. Then for users with this role you can expand the profile with extra fields. Here you can store for every user which courses they follow. Next you define a custom post type that allows you to store the video labelled with the courses for which it is meant. ...


1

Anyone with a login can access the admin area, even if they're just a subscriber that can read posts and nothing more. The crucial difference is not in the login, but in what parts of the admin one gets access to. A subscriber will only be able to see his personal profile, for instance. And admin gets access to everything. Others get something inbetween. ...


2

Yes, this is really very basic. If you are the admin, you can create new users and asign them a role. You could make your friend 'author', which would allow him to write and edit his own posts only, or make him an 'editor' if you also want him to edit other people's post.


2

Try this - rather than redo all the hard work that WordPress does for the view links, just calculate all the posts for the admin you want to "hide" and subtract from the existing post counts: function wpse_229427_get_hidden_admin_id() { return 3; // You could make this a setting or return a value conditionally } function wpse_229427_hide_admin_posts( $...


3

You need to register the CPT with your custom capability, then assign that specific cap to the user. When passing the arguments to register_post_type, set capability_type to your new capability, so the check turns into 'edit_cpts' instead of 'edit_post'. By setting 'capability_type' => [ 'cpt', 'cpts' ], 'cpt' will map to 'post' for standard ...


6

Clients get added by admins, clients have a parent child relationship with employees which makes filtering easy. So all we need to do is remove anything that doesn't have to do with employees and filter for employees with a certain meta value. First thing's first, whenever a new user is registered on the admin side of our CMS we will assign it a parent of ...


0

You can not "deactivate" plugins based on any condition since your code will run only after the plugin have been already initialized, and you can't reverse the initialization. You should target disabling a specific functionality of the plugin, but unless it has a documentation which specifically suggests how to do it, I would stay away from doing such a ...


1

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 (...


0

I got it resolved by adding 2 loops after each other. First loop display users with 'role__in' => 'sticky' while second loop display users with 'role__not_in' => 'sticky' It worked perfectly. Here is the code if it helps anyone. function Profiles() { echo "<div class='users-list'>" // First loop with sticky users $args = array( ...


0

If you read the code (in version 4.5.2 on line 164-173) you will see that orderby can be an array of values, coupled with order. So you could modify $args like this: $args = array( 'orderby' => array( array ('sticky' => 'DESC'), array ('registered' => 'DESC')), 'fields' => 'all_with_meta', ); ...



Top 50 recent answers are included