Home Forums WC Vendors Pro Support Vendor's products don't hide once vendor unsubscribe to my membership

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 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #67923
    Bola Gadalla
    Participant

    hello
    i want help with this problem i have and that is when a vendor who subscribed and posted products and then unsubscribe their products still show on the shop page and it goes under my name. is there a fix to this problem?
    i used this code to automatically change the role of the user to vendor once they subscribe and then change it to subscriber once they unsubscribe.

    // PAID MEMBERSHIPS PRO — UPGRADE TO VENDOR, DOWNGRADE TO SUBSCRIBER

    /*
    Members signing up for membership level #1 get “Vendor” role.
    Members cancelling are given the customer role.
    Admin users are ignored.
    */
    function my_pmpro_after_change_membership_level($level_id, $user_id)
    {
    //get user object
    $wp_user_object = new WP_User($user_id);

    //ignore admins
    if(in_array(“administrator”, $wp_user_object->roles))
    return;

    if($level_id == 1)
    {
    //New member of level #1. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    }

    elseif($level_id == 0)
    {
    //Cancelling. Give them Customer role.
    $wp_user_object->set_role(‘subscriber’);
    }
    }
    add_action(‘pmpro_after_change_membership_level’, ‘my_pmpro_after_change_membership_level’, 10, 2);

    Can someone please help me as soon as possible?

    #67949
    Anna
    Member

    @bola
    That’s code I had created and shared just as a starting point for people who wish to assign a vendor role to a PMPRO membership level.
    Any additional customization is up to you;
    For the products to be hidden, you’d have to find a way to either code in something to set them to a draft status, or manually set the products into a draft status if the vendor does not complete their membership payments.

    #68354
    Bola Gadalla
    Participant

    @FERVOUS
    hello sorry for the late reply

    Do you have any ideas on how to do that because am not a coding person. And yea that code is yours and i saw it a while back and it help a lot thank you for that.

    I wondering if its possible with a code or a plugin to hide MY products, my own products, since when the user cancels his subscription it goes under my name and site name.
    Or
    If its possible also if there’s a way to send it to a specific category and i would hide the category and its products.

    If you could help me in anyway where it would fix that problem would be great.

    #68399
    Bola Gadalla
    Participant

    @fervous

    Hello again,

    Another thing, am using wc vendor pro and when a user applies to be a vendor on the pro dashboard application in the payment section it doesnt show the stripe connect button for them to connect with stripe, but it shows when they go and configure the payment settings after they apply to be a vendor. Is there a way for it to show on the sign up page on pro dashboard vendor application so they would see it first hand then they have to go to the setting and all and they might forget to connect with stripe.

    @ben

    hello Ben i add you here just in case if Anna didn’t see this perhaps you would.

    #73401
    Ian Rarity
    Participant

    Hi @BOLA

    I’m currently adding monthly membership to my WC Vendors website and encountered the same issue as you. I have noticed a few posts from you trying to figure this one out, so I thought I would add how I got around this to help you out 🙂

    Firstly, I took the code that @FERVOUS kindly provided, and then added a couple of extra functions within her if statements.

    Basically what happens here is this: When a user cancels their membership they are downgraded to customer role (as per FERVOUS’ code), and then an extra function is fired that automatically marks all their products to draft (so not to show them in the shop). Now, a membership might be cancelled due to a declined payment and not because the vendor actually cancelled their membership. If the vendor signs up again with a new (or corrected) payment method, we don’t want the vendor to have to go through and manually publish all their products again. Therefor we add the same function again within the function that sets their role to vendor, but doing the opposite (set all products to published again).

    *I am not a very good coder*, I simply managed to get this function to work through trial and error – but it does seem to work exactly how I need it to on my development site.

    NOTE: I have removed the option for vendors to save draft products. If you allow them to save draft products, this could cause an issue as they would also get auto published too.

    Perhaps @FERVOUS and @BEN could have a quick look over to see if you spot anything that could pose any potential issues?

    // PAID MEMBERSHIPS PRO — UPGRADE TO VENDOR, DOWNGRADE TO SUBSCRIBER – AND UPDATE PRODUCT STATUS

    /*
    Members signing up for membership level #1 get “Vendor” role.
    Members cancelling are given the customer role.
    Admin users are ignored.
    Vendor products status is updated to draft if membership cancelled or published if active.
    */
    function my_pmpro_after_change_membership_level($level_id, $user_id)
    {
    //get user object
    $wp_user_object = new WP_User($user_id);

    //ignore admins
    if(in_array(“administrator”, $wp_user_object->roles))
    return;

    if($level_id == 1)
    {

    function update_product_status( $user_id, $new_role, $old_roles ) {

    global $wpdb;

    $update = array(
    ‘post_status’ => ‘publish’
    );

    $where = array(
    ‘post_type’ => ‘product’,
    ‘post_status’ => ‘draft’,
    ‘post_author’ => $user_id
    );

    $updated = $wpdb->update( $wpdb->posts, $update, $where );
    }

    add_action( ‘set_user_role’, ‘update_product_status’, 10, 3 );

    //New member of level #1. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    }

    elseif($level_id == 0)
    {

    function update_product_status( $user_id, $new_role, $old_roles ) {

    global $wpdb;

    $update = array(
    ‘post_status’ => ‘draft’
    );

    $where = array(
    ‘post_type’ => ‘product’,
    ‘post_status’ => ‘publish’,
    ‘post_author’ => $user_id
    );

    $updated = $wpdb->update( $wpdb->posts, $update, $where );
    }

    add_action( ‘set_user_role’, ‘update_product_status’, 10, 3 );

    //Cancelling. Give them Customer role.
    $wp_user_object->set_role(‘customer’);
    }
    }
    add_action(‘pmpro_after_change_membership_level’, ‘my_pmpro_after_change_membership_level’, 10, 2);

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