Home Forums WC Vendors Pro Support Vendor Approval Filter?

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #56230
    Yasa
    Participant

    Hi,
    I would like to call a function when a vendor approved. Do you have a filter or any solution for that?

    Right now I am controlling it on vendor sign-up form with this

    add_action( 'init', 'create_submerchant' );
    
    function create_submerchant() {
         if( isset($_POST['vendor-signup'])) {
         ..........
         }
    }

    I created a hidden input(vendor-signup) in order to control it but this calls the function every time they apply. I would like to use it when vendor approved, any code any clue will be appreciated.

    Thank you!

    #56252
    Anna
    Member

    I can guide you to where you may be able to find what you need, in WC Vendors (free):
    wp-content/plugins/wcvendors/classes/admin/class-vendor-applicants.php

    And then perhaps looking at the trigger function in the approved vendor email code:
    wp-content/plugins/wcvendors/classes/admin/emails/class-wc-approve-vendor.php

    #56308
    Yasa
    Participant

    Thank you for the info, everything works fine. However, I can not overwrite wcvendors/classes/admin/class-vendor-applicants.php under my child theme. Should I move it somewhere else? Iam using mraketplace theme btw. I already overwritten childtheme/wc-vendors/front/vendor-signup-form.php, but it didn’t work for class-vendor-applicants.php (childtheme/wc-vendors/classes/admin/class-vendor-applicants.php).

    #56325
    Anna
    Member

    @canyasa
    That’s not a template file wcvendors/classes/admin/class-vendor-applicants.php – so it cannot be overridden as you would a template file. It is a core file.
    You would have to make changes using an action, a filter, or by directly modifying the core files (not recommended, as that is not upgrade safe).

    #56340
    Yasa
    Participant

    Thank you Anna. I tried use hooks but couldn’t figure it out, also I asked on stackoverflow too. I know it is custom work but maybe you guys know how to use right hook on this case.

    Here is my custom function:

    function create_submerchant($user_id) {
    
            $user_info = get_userdata($user_id);
    
            $store_country = 'TR';
            $store_name = $user_info ->pv_shop_name;
            $store_owner_name = $user_info ->_wcv_custom_settings_bankahesapadi;
            $store_owner_lastname = $user_info ->_wcv_custom_settings_bankahesapsoyadi; 
            $store_email = $user_info -> user_email;
            $store_address = $user_info ->_wcv_custom_settings_banka_adres;
            $store_iban = $user_info ->_wcv_custom_settings_bankaiban;
            $store_owner_id = $user_id;
            $store_owner_tc = $user_info ->_wcv_custom_settings_kimlikno;
    
            create_personal_sub_merchant($store_country,$store_name,$store_owner_name,$store_owner_lastname,$store_email,$store_address,$store_iban,$store_owner_id,$store_owner_tc);
    
    }

    And this is how I use my function under class-vendor-applicants.php:

    public function user_row_actions_commit()
        {
            if ( !empty( $_GET[ 'action' ] ) && !empty( $_GET[ 'user_id' ] ) ) {
    
                $wp_user_object = new WP_User( (int) $_GET[ 'user_id' ] );
    
                switch ( $_GET[ 'action' ] ) {
                    case 'approve_vendor':
                        $role = 'vendor';
                        add_action( 'admin_notices', array( $this, 'approved' ) );
                        do_action( 'wcvendors_approve_vendor', $wp_user_object );
                        create_submerchant ($_GET[ 'user_id' ]);
                        break;
    
                    case 'deny_vendor':
                        $role = 'customer';
                        add_action( 'admin_notices', array( $this, 'denied' ) );
                        do_action( 'wcvendors_deny_vendor', $wp_user_object ); 
                        break;
    
                    default:
                        // code...
                        break;
                }
    
                $wp_user_object->set_role( $role );
    
            }
        }

    But I don’t know how to bind my function with $wp_user_object’s user_id using hooks. As a summary, I am trying to call my function(using approved vendor’s id) when a vendor approved.

    #56356
    Yasa
    Participant

    I have found the right hook, thanks anyway.

    add_action(‘wcvendors_approve_vendor’, ‘function’, 10, 1);

    #56357
    Anna
    Member

    Hello,
    I think you are going to need to work with this hook: wcvendors_approve_vendor
    , that is, if I am clear about what your end goal is.

    #56358
    Anna
    Member

    Ahh and I see you already answered when I was digging this up– glad it is working for you. 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.