Manual Badges

Home / Code Snippets / Manual Badges

By default, myCRED will give users a badge automatically based on your setup. This snippet will allow you to create badges that will never be automatically awarded to users. These manual badges would need to be added manually by editing the user in the admin area.

Add to your child theme's functions.php file and create badges in the admin area using the reference "Badge is awarded manually".

Last edited January 26, 2016

    1. Sure, you can just use add_user_meta to add the badge to the user:

      $user_id = 2;
      $badge_id = 1;
      $badge_level = 0; // zero for first level
      add_user_meta( $user_id, 'mycred_badge' . $badge_id, $badge_level, true );
      

      You will need to set the custom user meta’s value to the level you want to award. Use zero if you just have one level or if you want to award the first level.

Leave a Reply