create blue badge tick mark for wordpress author role

To create a blue badge tick mark for the WordPress author role, you can use a plugin like “User Role Editor” or add custom code to your theme’s functions.php file.

With the “User Role Editor” plugin:

  1. Install and activate the plugin.
  2. Go to Users > User Role Editor.
  3. Select the Author role from the list of roles.
  4. Scroll down to the “Custom Capabilities” section and add a new capability called “has_blue_badge”.
  5. Save changes.

With custom code:

  1. Add the following code to your theme’s functions.php file:
function add_blue_badge_to_author() {
$author = get_role( 'author' );
$author->add_cap( 'has_blue_badge' );
}
add_action( 'admin_init', 'add_blue_badge_to_author' );
  1. Create a new CSS class called “blue-badge” and add it to your stylesheet with the appropriate styling for a blue badge tick mark.
  2. Use the following code to add the blue badge tick mark to the author’s name on the frontend:
if( user_can( $author_id, 'has_blue_badge' ) ) {
echo '<span class="blue-badge"></span>';
}

After doing any of the above steps, you can then use the custom capability or class to display the blue badge tick mark for authors on the frontend of your website.

Related Posts

Leave a Reply