Showing different images depending on user role

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

Overwrite user role

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

Remove from a div by class name from post page if post author role is not administrator

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

Removing Admin Bar Node Based on Role

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

Restrict certain roles registrations by domain

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

Select dropdown with 2 choices from foreach

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

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