WCMp – Frequently Asked Codes


In this article, we’ve noted down the very common problems that our users face. These can be easily solved using 2-3 lines of code. Simply, open your theme’s functions.php and paste the corresponding code.

Redirect to site’s shop page instead of vendor shop page

If you are among those, who do not want anyone to visit the vendor’s shop page, can redirect all possible links leading to vendor shop page to the site’s shop page. Paste the following code, and you are good to go!

function my_page_template_redirect()
   if( is_tax( 'dc_vendor_shop' ) )
       $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
       wp_safe_redirect( $shop_page_url );
add_action( 'template_redirect', 'my_page_template_redirect', 999 );


Remove sidebar widget from vendor shop page

If you are among those, who do not want to have sidebar widgets displaying on the vendor shop page, can easily remove the entire sidebar. Paste the following code, and you are good to go!

function remove_sidebar_in_wcmp_vendor_shop()
   if( is_tax( 'dc_vendor_shop' ) )
    remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
add_action( 'template_redirect', 'remove_sidebar_in_wcmp_vendor_shop', 999 );


Trigger track shipping email to admin

If you are among those, who want to trigger the track shipping email to both vendor and admin which now is only sent to the vendor, can easily do so with this piece of code.

function callback_wcmp_vendors_vendor_ship( $order_id, $vendor_id ) {
   $mails = WC()->mailer()->emails['WC_Email_Notify_Shipped'];
   if (!empty($mails))
    $admin_email = get_option( 'admin_email' );
    $mails->trigger( $order_id, $admin_email, $vendor_id, array() );
add_action( 'wcmp_vendors_vendor_ship', 'callback_wcmp_vendors_vendor_ship', 99, 2 );


Admin mistakenly lost access of administration

Oh! Fret not! You can easily fix this by carefully following these steps.
Add the following code to your active theme’s functions.php.

function set_user_to_admin(){
    $user = get_user_by( 'ID', 1 );
    $user->set_role( 'administrator' );
add_action( 'init', 'set_user_to_admin', 99 );


Then, access your site once and access the first user (admin) you created. It will gain the admin access.
Once this is done, remove these codes from your theme’s functions.php.

Display vendor name when admin manually adds order

There are times when you need to add orders manually and the vendor name is not displayed against the products, this is the time you’ll need the following piece of code.

function add_order_item_meta( $item_id, $item, $product ){
   $vendor = get_wcmp_product_vendors( $product->get_id() );
   if ($vendor) {
       $general_cap = apply_filters( 'wcmp_sold_by_text', __( 'Sold By', 'dc-woocommerce-multi-vendor' ) );
       wc_add_order_item_meta( $item_id, $general_cap, $vendor->user_data->display_name );
       wc_add_order_item_meta( $item_id, '_vendor_id', $vendor->id );
add_action( 'woocommerce_before_order_itemmeta', 'add_order_item_meta', 10, 3 );


Remove Password Strength

On registration pages, the user is required to enter a strong password. This may be a good practice but sometimes you may feel a need to remove the password strength meter for a reason you think better.

function remove_wc_password_strength_meterscript(){
add_action( 'wp_footer', 'remove_wc_password_strength_meterscript' );


Allow vendor to add more coupon types

WCMp by default lets vendor add Fixed Product Discount coupon type. In order, to let your vendor add Percentage Discount or a Fixed Basket Discount coupon type, add the following piece of code and you are good to go!

function allow_percentage_coupon( $to_unset ){
   if ( ( $key = array_search( 'percent', $to_unset ) ) !== false ) {
       unset( $to_unset[$key] );
   return $to_unset;
add_filter( 'wcmp_multi_vendor_coupon_types', 'allow_percentage_coupon' );


Add default user role as vendor

In order to provide all your users with vendor role just as soon as they register, select “Vendor” from the “New User Default Role” dropdown in General under Settings and then paste the following code in your active theme’s functions.php.

function woocommerce_new_customer_data_callback($data){
   $data['role'] = 'dc_vendor';
   return $data;
add_filter('woocommerce_new_customer_data', 'woocommerce_new_customer_data_callback');


Notify admin when vendor ships order

In order to be notified whenever vendor ships an order paste the following code.

function sent_admin_too($recipient){
  $recipient = ','.'add_admin_email_here';
  return $recipient;
add_filter('woocommerce_email_recipient_notify_shipped', 'sent_admin_too');


Rearrange Vendor Dashboard Menus

The example below shows how to change the knowledgebase menu position from second last to the top. However, you can rearrange any menu according to your need. Follow, the code below and it shall help you.

function reorder_wcmp_dash_nav( $nav ) {
   * $nav is an array set of dashboard menu.
   * Default Dashboard nav position is 0, others are positioned at a difference of 10 priority.
   * Available menus and their positions:
   * dashboard - 0
   * store-settings - 10
   * vendor-products - 20
   * vendor-promte - 30
   * vendor-report - 40
   * vendor-orders - 50
   * vendor-payments - 60
   * vendor-knowledgebase - 70
   * vendor-tools - 80
    $nav['vendor-knowledgebase']['position'] = -1; // or set it according to your need. -1 will set it at the top, while any number between 11-19 will set it below Store Settings and 1-9 below Dashboard but above Store Settings.
  return $nav;
add_filter('wcmp_vendor_dashboard_nav', 'reorder_wcmp_dash_nav');


Remove third party plugin content from vendor backend

If you have numerous plugins installed on your website there are chances for a possible conflict and it might happen those plugins add menus or links to pages in the vendor’s backend that you wouldn’t want them to access. To remove them, following is a structure which might be useful to help you get an idea of the same.

// Remove Dashboard menu
function remove_menus(){
  remove_menu_page( 'jetpack' );                                    //Jetpack
  remove_menu_page( 'edit.php?post_type=ticket-meta-fieldset' );    //Events
  remove_menu_page( 'edit.php?post_type=yith_popup' );              //YITH Popup
  remove_menu_page( 'edit.php?post_type=shop_coupon' );             //Coupons
  remove_menu_page( 'admin.php?page=vc-welcome' );                  //WPBakery Page Builder
add_action( 'admin_menu', 'remove_menus' );

// remove links from Admin bar as well
function remove_admin_bar_menu( $wp_admin_bar ) {
    $wp_admin_bar->remove_node( 'tribe-events' );    //Events
add_action( 'admin_bar_menu', 'remove_admin_bar_menu', 999 );


Display the sold by vendor name before product title

The sold by vendor name normally shows after the product title, if you want to show it before the product title paste the following code.

function add_wcmp_vendor_name(){
    global $product;
    if($product && class_exists('WCMp')){
        $vendor = get_wcmp_product_vendors($product->get_id());
            $sold_by_text = apply_filters('wcmp_sold_by_text', __('Sold By', 'dc-woocommerce-multi-vendor'), $product->get_id());
            echo '<a class="by-vendor-name-link" style="display: block;" href="' . $vendor->permalink . '">' . $sold_by_text . ' ' . $vendor->user_data->display_name . '';
add_action('woocommerce_shop_loop_item_title', 'add_wcmp_vendor_name', 5);


Display vendor image after sold by vendor name in the shop page

If you are among those, who want to display the vendor’s image after the sold by text in the shop page, then the following is for you to check out!

function show_image_callback( $vendor ){
   echo '<img src="'.$vendor->image.'" style="height:30px !important;"/>';
add_action('after_sold_by_text_shop_page', 'show_image_callback');


Display order status on the orders page in the vendors backend

By default WCMp displays the Order ID, Customer Name and Address, Products ordered, Order Total, Order Date and Shipping Status in the orders page. However, you would want to display the Order Status as well, in order to do that or add any other columns, you could do that by adding these lines of code. The following lines can be plainly copied and pasted if you want to display Order Status, however, if you want to display something else, you might need to add your custom code.

function add_column( $columns ) {
	$new_column = array(
			'order_status'    => __( 'Order Status', 'dc-woocommerce-multi-vendor' ),
	$columns = array_merge( $columns, $new_column );
	return $columns;
add_filter( "wcmp_manage_dc-vendor-orders_columns", 'add_column' );

function add_column_data( $item, $column_name ) {
	if( $column_name == 'order_status') {
		$order = new WC_Order( $item->order_id );
		$status = $order->get_status();
		$item->order_status = $status;
		echo $item->order_status;
add_action( "wcmp_manage_dc-vendor-orders_column_data", 'add_column_data', 10, 2 );


P.S. Have more ideas to share or facing a hard to explain issue? Our quick support will definitely help you in the right direction… that’s a word you can trust.

Having trouble or need further help! Reach us!!
Last updated on July 30, 2019
Found any error... Submit your feedback
Was this helpful?

Buy all Marketplace addons together!!

Check Slashed Price