capability 'edit commissions' for managers

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Groups & Staffs capability 'edit commissions' for managers

This topic contains 3 replies, has 2 voices, and was last updated by Avatar Sushobhan 1 week, 2 days ago.

  • Author
    Posts
  • #92063
    Avatar
    Mcflait
    Participant

    Hi! i use the plugin for create managers who handle several shops… and so far so good.

    But i dont know what capability i have to deactivate for hiding the commission settings from ‘add product’ page for the managers. I tried with the group capability and the general one for managers but nothing. Im lost here. :/

    Thanks!

  • #92332
    Avatar
    Sushobhan
    Keymaster

    Hi,
    Please add this code to your site –

    function disallow_commission_manage_for_managers() {
        if(wcfm_is_manager()) return false;
        return true;
    }
    add_filter('wcfm_is_allow_commission_manage', 'disallow_commission_manage_for_managers');

    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/
    Thank You

  • #94903
    Avatar
    Mcflait
    Participant

    I tried with this filter, but sadly also disable the ‘store selector’.

    so in class-wcfm-vendor-support we had:

    
    if( !wcfm_is_vendor() && apply_filters( 'wcfm_is_allow_commission_manage', true ) && apply_filters( 'wcfm_is_allow_view_commission', true ) ) {
    	// Associate Vendor
    	add_action( 'end_wcfm_products_manage', array( &$this, 'wcfm_associate_vendor' ), 490 );
    	add_action( 'after_wcfm_products_manage_meta_save', array( &$this, 'wcfm_associate_vendor_save' ), 490, 2 );
    

    i took it out and make and if just with (!wcfm_is_vendor) (yeah, hardcoding with other changes via commits on github). If you had another workarund please let me now. Thanks!

  • #95096
    Avatar
    Sushobhan
    Keymaster

    Changing core files is not the recommended way to do any customization. Better remove the action and filters responsible for commission management after checking the user role –

    function remove_comission_for_managers() {
        global $WCFMmp;
        if ( wcfm_is_manager() ) {
            remove_action( 'after_wcfm_products_manage_tabs_content', array( $WCFMmp->wcfmmp_product, 'wcfmmp_product_commission' ), 500, 4 );
            remove_action( 'after_wcfm_products_manage_meta_save', array( $WCFMmp->wcfmmp_product, 'wcfmmp_product_commission_save' ), 500, 2 );
    
            // Variation Commission
            remove_filter( 'wcfm_product_manage_fields_variations', array( $WCFMmp->wcfmmp_product, 'wcfmmp_commission_fields_variations' ), 500, 7 );
            remove_filter( 'wcfm_variation_edit_data', array( $WCFMmp->wcfmmp_product, 'wcfmmp_commission_data_variations' ), 500, 3 );
            remove_filter( 'wcfm_product_variation_data_factory', array( $WCFMmp->wcfmmp_product, 'wcfmmp_product_variation_commission_save' ), 500, 5 );
        }
    }
    
    add_action( 'wcfm_init', 'remove_comission_for_managers', 20 );

    I’ll pass this to my development team and ask them to add one additional filter so that in future we can gracefully remove the ‘Commission’ tab without removing the ‘Store’ tab.

    Thanks!

You must be logged in to reply to this topic.