Hello @jennyong ,
Thanks for contacting us. Hope you are doing well.
You can use mycred_get_badge function to achieve it.
Here is the link to the documentation.
Documentation Link
You will have to do some custom coding to do it properly.
Let me know if you have any questions.
Thanks & Regards,
WP Experts Support Team.
Hi this mycred_get_badge does not return badge id. Or which hook that I can use to return badge id? Because I need badge id to assign user role to user. Kindly advise. Thank you
-
This reply was modified 2 years, 6 months ago by
jennyong.
You can get Badge ID’s and user roles using the below code snippet:
$badges = array(); if (class_exists('myCRED_Badge')){
$badge_ids = mycred_get_badge_ids();
foreach( $badge_ids as $id ) { $badges[$id] = get_the_title( $id ); }
}
$wp_roles = wp_roles();
$roles = array();
foreach( $wp_roles->roles as $role => $name ) { $roles[$role] = $name['name']; }
Let me know if you have any further questions.
Thanks
Hi,
can I know what is the field name to store the badge name?
Thank you
It is saved in wp_posts table in post_name field