• Resolved filippodotnext

    (@filippodotnext)


    Hi,

    I’m trying to create a product by developing a frontEnd Form.

    The product is created and I received the mail “Hello! A vendor ( UserTest ) has added a new product awaiting review.”

    But when I look the table Products in the WP Admin panel the column “Vendors” is not setted.

       $post_information = array(
            'post_title' => wp_strip_all_tags( $_POST['postTitle'] ),
    		'post_type' => 'product',
            'post_status' => 'pending'
        );
     
        $post_id = wp_insert_post( $post_information );
        $currentUser = wp_get_current_user();
    
        wp_set_object_terms($post_id , array('Economy'), 'product_cat');
        wp_set_object_terms($post_id , array($currentUser), 'taxonomy- 
        wcpv_product_vendors');

    The taxonomy product_cat works fine, but with a similar approach the vendors column has not been setted.

    I think the problem is that $currentUser is not the right parameter, what should I pass ?

    Thanks for your help

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    I think the problem is that $currentUser is not the right parameter, what should I pass ?

    I would use set_role() instead of wp_set_object_terms(): https://tommcfarlin.com/wordpress-user-role/

    Kind regards,

    Thread Starter filippodotnext

    (@filippodotnext)

    Hi, thanks for your reply.

    The current user is already a “vendor admin” so i I don’t need to set him with a role.

    I’m trying to associate him to the product object, something like:
    WC_Product->setVendor(); but searching in the class abstract-wc-product I cannot find anything.

    Plugin Support con

    (@conschneider)

    Engineer

    Hi again,

    I’m trying to associate him to the product object, something like:
    WC_Product->setVendor();

    I see. I would use what Product Vendors has available for this already.

    WC_Product_Vendors_Vendor_Admin->save_post()

    Kind regards,

    Kenin

    (@kbassart)

    Automattic Happiness Engineer

    Hi there,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Setting Vendor from Frontend’ is closed to new replies.