Display users by role

What I understand from your code: You want to list users with author role. You’re in the right direction, however, following are some tips to make your code better. Use role id in lowercase syntax. Change Author to author for role property. Get the results for once and avoid repeated calls. Save the results like … Read more

Send email to user if their role is changed to Author

Check for the value of $new_role before sending the email, if it isn’t author then do nothing function user_role_update( $user_id, $new_role ) { if ( $new_role == ‘author’ ) { $site_url = get_bloginfo( ‘wpurl’ ); $user_info = get_userdata( $user_id ); $to = $user_info->user_email; $subject=”Role changed: ” . $site_url . ”; $message=”Hello ” . $user_info->display_name . … Read more

WordPress show content if current user get spesific role and spesific meta value

Your question needs some additional context, but here’s a generic approach to what you’ve described. if ( is_user_logged_in() ) { $user = wp_get_current_user(); // Does user have the required role? if ( in_array( ‘some_role’, $user->roles ) && ‘some_meta_value’ == get_user_meta( $user->ID, ‘some_meta’, true ) ) { // Special content… } else { // User doesn’t … Read more

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