2

How to add the custom badge to store-listing after the vendor name with a specific vendor id? the below code works but show for all vendors, indeed I need to run this code only for a particular vendor. enter image description here

     function display_author_name_store_listing() {
     if (!is_plugin_active('dokan-lite/dokan.php')){
         return"";
     }
     printf("custom badge");
     }   
     add_action( 'dokan_store_list_loop_after_store_name', 'display_author_name_store_listing');
mujuonly
  • 11,370
  • 5
  • 45
  • 75
Behzad
  • 75
  • 1
  • 7

1 Answers1

2
function display_author_name_store_listing() {
    if (!is_plugin_active('dokan-lite/dokan.php')) {
        return "";
    }

    global $wpdb;

    $ubicon = $wpdb->prefix . 'ubicon'; //user badge verified users
    // Get the author ID (the vendor ID)
    $vendor_id = get_post_field('post_author', get_the_id());

    $result = $wpdb->get_row($wpdb->prepare("SELECT * FROM $ubicon WHERE link_id = %d", $vendor_id));

    $bage_url = $result->badge_url;
    return $bage_url;
}

add_action('dokan_store_list_loop_after_store_name', 'display_author_name_store_listing');
mujuonly
  • 11,370
  • 5
  • 45
  • 75
  • would you please just add some words after vender_name with id 1? – Behzad Mar 26 '23 at 16:50
  • this snippet code show the badge for all sellers, ijust retrieve the badge from user meta and idlike to show the badge for the seller who, has the same id with the user id something like: $user_id = 5; if($seller_id == $user_id){ echo badge } – Behzad Jul 23 '23 at 14:43