A deal you can't resist! Get upto 35% Off on this entire cyber week.

01Day 18Hr 56Min 15Sec

Getting the numbers of registered vendors

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 3 reply threads
  • Author
    • #108902
      Steven Kuijpers

      Hi there. I want to display the total number of store vendors on my website. So the amount of companies that have a webstore in our marketplace.

      What is database entry that I can display? For example to get in a function in functions.php


    • #108913

      Thanks for getting in touch.
      You can use the following snippet to do that. You can use the shortcode like this [wcfm_vendor_count] or [wcfm_vendor_count status="active/inactive/all"], if you don’t pass status attribute it will show count of active vendors only.

      function wcfm_vendor_count_shortcode( $attr ) {
          $status = 'active';
          $result = count_users();
          $avail_roles = array_merge( array( 'wcfm_vendor' => 0, 'disable_vendor' => 0 ), $result['avail_roles'] );
          if ( isset( $attr['status'] ) && in_array( $attr['status'], array('all', 'active', 'inactive') ) )
              $status = $attr['status'];
          if($status === 'inactive')
              return absint( $avail_roles['disable_vendor'] );
          if($status === 'all')
              return absint( $avail_roles['wcfm_vendor'] ) + absint( $avail_roles['disable_vendor'] );
          return absint( $avail_roles['wcfm_vendor'] );
      add_shortcode( 'wcfm_vendor_count', 'wcfm_vendor_count_shortcode' );

      Add this code to your child theme’s functions.php

      In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/

      Let me know how it goes.

    • #108916
      Steven Kuijpers

      That works perfectly! Thank you.

      Did you just write that or was it an existing function. Can I find others like this somewhere?

    • #108917

      It is a custom function that I wrote for you 🙂
      If there is anything else, you can let me know.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.