Why the capability ‘activate_plugins’ is needed to allow a role to see all posts/pages/comments?
Why the capability ‘activate_plugins’ is needed to allow a role to see all posts/pages/comments?
Why the capability ‘activate_plugins’ is needed to allow a role to see all posts/pages/comments?
What’s the variable $user_info in you code? Probably you mean $commentator_info? If yes, this is certainly the error. You are trying to extract wp_capabilities (?) from a non-initialized variable ($user_info). Try this: <?php $comment_id = get_comment_ID(); $comment_data = get_comment($comment_id); $commentator_id = $comment_data->user_id; $commentator_info = get_userdata($commentator_id); // get_userdata, with the user ID specified, returns a WP_User … Read more
I don’t use this plugin for a while, don’t you need to customize the shortcode for each form, one should be role=”student” and the other one role=”employer”. You can also use the filter add_filter( ‘simplr_validate_form’, ‘my_simplr_validate_form’, 10, 3 ); A simple example, assuming the page for the registration is 1 for the student and 2 … Read more
Basically you are asking a function to check the post author role. You can use user_can() function. if(user_can(‘administrator’)) { //Write your code if the admin } current_user_can() : https://codex.wordpress.org/Function_Reference/current_user_can user_can() : https://codex.wordpress.org/Function_Reference/user_can
This is happening because the ‘edit’ capability allows adding new posts/pages. A quick google shows there are ways to remove the creation capability; I haven’t tested any of them.
WP_User has a roles array. Get the current user with wp_get_current_user() and check if your role is in the array. add_action( ‘admin_bar_menu’, ‘remove_new_content_menu’, PHP_INT_MAX ); function remove_new_content_menu( $wp_admin_bar ) { // get the current user $user = wp_get_current_user(); // define roles that cannot see the `new content` button $blacklisted_roles = array(‘grocery’, ‘subscriber’); // remove the … Read more
The problem turned out to be a form software bbpress interfering in some way with the queries for user permissions. If you find yourself in a similar situation there are a ton of resources on google, some of which may help and some that won’t. Try uninstalling your plugins (ne-name your plugins folder) Try re-installing … Read more
You’ll want to checkout the registration_errors filter. Make sure the role is being posted within the particular registration form. Instead of conditionally adding your action you have to check within the filter if role and email are valid. add_action( ‘registration_errors’, ‘wpse_248123_registration_errors’ ); function wpse_248123_registration_errors( $sanitized_user_login, $user_email, $errors ) { if ( empty( $_POST[‘role’] ) ) … Read more
You don’t specify whether you are trying to make all of these items available to all user roles (which would mean having to add custom capabilities) – so I’m assuming you only want the ability to customize menu order by user. My approach for this was to get all roles available to the currently logged-in … Read more
You can use in_array to check if the name of the role is either customer or shop_manager add_action(‘register_form’, ‘myplugin_register_form’); function myplugin_register_form() { global $wp_roles; echo ‘<select name=”role” class=”input”>’; foreach ($wp_roles->roles as $key => $value): if ( in_array( $key, array(‘customer’, ‘shop_manager’) ) ) echo ‘<option value=”‘ . $key . ‘”>’ . $value[‘name’] . ‘</option>’; endforeach; echo … Read more