I have a quick question and I hope some of you can help me out.

The thing is I have this plugin that can put a badge to a profile picture manually. But since my website is a community it would be kind of a pain in the a** (sorry for the language) if I have to put the badge manually for every user with a certain role.

I try to do that automatically but I'm stuck on the part where I need to get the user ids from all premium users (s2member_level1)so that I can check a box in the backend automatically.

I'm searching for the correct code that simply does this logic here:

<input type="checkbox" name="verified" value="1" 
    if (get all users with membership level "s2member_level1") {echo 'checked'; }
    else {echo'';} 

All i have for now is this:

<td><input type="checkbox" name="verified" value="1" <?php    echo 'checked="checked"'; ?> />

Here is a screenshot of how it should looks like if the user has the s2member_level1:


I coustomized this in the admin.php of the Plugin BuddyVerified version 2.2. This is the relevant code from the admin.php that generates the form shown in the screenshot:

function buddyverified_inner_meta_box() {

$user_id = isset($_GET['user_id']) ? $_GET['user_id'] : 0;
$meta = get_user_meta( $user_id, 'bp-verified', true) ? get_user_meta( $user_id, 'bp-verified', true) : null ;
$verified = get_user_meta( $user_id, 'bp-profile-verified', true) ? get_user_meta( $user_id, 'bp-profile-verified', true) : null ;


<table cellspacing="3px" style="border-collapse: collapse;">

            <td style="vertical-align:middle">Verify User:</td>
            <td><input type="checkbox" name="verified" value="1" <?php  echo 'checked="checked"'; ?> />
        <tr class="alt">
            <td style="vertical-align:middle">Badge:</td>
            <td><img src="<?php echo VERIFIED_URL; ?>/images/5.png"></td>
        <tr class="alt">

            <td><input type="radio" name="verified_image" value="5" <?php if ($meta['image'] == '5') echo 'checked="checked"' ?> /></td>
            <td style="vertical-align:middle">Badge Text:</td>
            <td><input type="text" id="verified_text" name="verified_text" placeholder="Verified User" value="<?php echo $meta['text'] ?>" size="25" /></td>
        <tr class="alt">
            <td >Activity Badge:</td>
            <td><input type="radio" name="verified_activity" value="yes" <?php echo 'checked="checked"' ?> />Yes </td>
            <td><p>Adds badge to activity stream avatar</p></td>
            <td >Profile Badge:</td>
            <td><input type="radio" name="verified_profile" value="yes" <?php if ( $meta['profile'] == 'yes') echo 'checked="checked"' ?> />Yes </td>
            <td><p>Adds badge to profile avatar</p></td>



I'm currently working with Wordpress Version 4.6.1, Buddypress 2.7.2 and s2Member Framework Version 2.7.3

Thanks for your help.


It seems that s2Member does not bring the functionality out of the box. So I may not have a direct answer to your question, but a few suggestions instead:

  • In your case I would probably try to combine s2Member with myCred (https://mycred.me/add-ons/badges/) for example like this: the only way to earn 'points' would be upgrading to a pro account / role. Then a badge would be applied and displayed respectively.

  • Another option could be to use get_queried_object to get the user role – then adjust the output accordingly: "Show different badge based upon the user role"

  • A third probably a but more complex option could be to use the plugin BadgeOS: '… a powerful free plugin to WordPress that lets you easily create achievements and issue sharable badges as your users succeed. ' (http://badgeos.org/)

  • Last but not least: I'm personally actually using PMPro instead of s2members – and they offer an add-on that would do just that: 'Assign unique member badges (images) to each membership level and display via a shortcode or template PHP function' (https://www.paidmembershipspro.com/add-ons/plus-add-ons/member-badges/)

  • Thanks for your answer. I tried the first sugestion and its not working out for me. I tried using PMPro instead of s2member before but since i need the extra profile fields that i can assign to the different levels with s2member it's not an option too. so i will try the second suggestion. maybe that will work out. – Bexx Nov 18 '16 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.