Register Login Featured
Stats: 2340 members, 1523 topics. Date: Friday, 17th August 2018


General Wordpress Blogspot Forums Crypto Traffic Money

Verification Badge For WordPress, Say No More Doc!

Verification Badge For WordPress, Say No More Doc! by : 12:04 pm On October 10, 2017

A verification badge is now a common thing over the internet. Probably you’ve seen it on Facebook, Twitter, Instagram etc. No, I’m not here to talk about the history or origin of the verification badge. I’m here to show how to add a verification badge facility on your WordPress site. This is gonna be interesting! Look, I know not everyone is a code savvy. So, I wrote a tiny plugin for this. The plugin is attached in the attachment section below the post.

Setup the verification badge

First of all, you’ve to download the plugin. Then log in to your WordPress dashboard with admin permission and navigate to “Plugins > Add New > Upload Plugin” and upload the archive that you’ve downloaded earlier. Then install the plugin and activate. Now, we’re all set!

Install Plugin From ZIP Archive WordPress
Then, just navigate to “Dashboard > Users” and select the user you want to verify and click “Edit”.  If you are an admin of the site, you should see an option to verify the user at the bottom of their profile page.

Enable Verification Badge WordPress

That was the UI part. We need to show the verification badge on the site, right? The plugin provides two functions for you. wp_verification_badge($user_id) and has_verification_badge($user_id). Both functions take a user ID as an argument. Now let’s break down the functions.

In this example, we’re assuming we are on the author page aka author.php template.

PHP
// In the author page we can get the author from the slug
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
$user_id = $curauth->ID; // The User ID

Now we have the user ID on the variable $user_id. Do display the verification badge use this code.

PHP
if ( function_exists( 'wp_verification_badge' ) ) {
    wp_verification_badge($user_id); // will print out the badge image html
}

But I don’t like that badge. I want to use my own badge and want to customize the HTML!
I hear you, Watson. Remember about the other function? The function has_verification_badge($user_id) returns the verification status of the user. If verification badge was given to the user it will return true otherwise false. Let’s see it in action.

PHP
if ( function_exists( 'has_verification_badge' ) && has_verification_badge($user_id) ) {     // The user is verified!     // Do something! show a verification image, text whatever you want }

Conclusion

I’ve future plans for this plugin. I shall make an option page, allow admins to upload & choose their very own verification badge, submit the plugin to WordPress plugin directory etc. But that’s in future, who has seen the future?
If you face any problem regarding this plugin please use the comment box. And don’t forget to use the share buttons!
** It feels so empty without me ??**

Attached Files

0

Publication author

offline 2 months

GitHubNg.Com

18

GitHubNG.com - An All in one Solution Forum Where we discuss Blogging related Issues, Make Money Online, Traffic and Adsense tips. Etc.

Comments: 103Publics: 664Registration: 31-10-2017

Reply


You must be logged in to post a comment.

 


(Go Up)

Links: (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)

GitHubNg.Com - Copyright © 2017 - Henry Ijogu. All rights reserved. See How To Advertise.
Disclaimer: Every member is solely responsible for anything that he/she posts or uploads on this Forum.

v3.0.1

Authorization
*
*
Registration
*
*
*
Password generation