Assign member type based on user meta
-
Hi all, I’m trying to automatically assign users to specific member types (seller & supplier) based on each user’s meta (reseller & supplier) that i made. the website i’m developing is using wc vendors pro + woocommerce. Here’s some lines i wrote based something i found here.
function using_mt_register_member_types() { bp_register_member_type( 'seller', array( 'labels' => array( 'name' => __( 'Seller', 'using-mt' ), 'singular_name' => __( 'Sellers', 'using-mt' ), ), 'has_directory' => 'sellers' ) ); bp_register_member_type( 'supplier', array( 'labels' => array( 'name' => __( 'Supplier', 'using-mt' ), 'singular_name' => __( 'Suppliers', 'using-mt' ), ), 'has_directory' => 'suppliers' ) ); } add_action( 'bp_init', 'using_mt_register_member_types' ); function assign_member_type ($user_id, $member_type) { $the_id = bp_displayed_user_id(); $vendor_type = get_user_meta($the_id , '_wcv_custom_settings_vendortype', true ); $wp_user_object = new WP_User($user_id); if($vendor_type == 'designer') { bp_set_member_type( $user_id, 'seller' ); } } add_action( 'bp_init', 'assign_member_type' );
Member types seller & supplier is created with no problem, but I will get error with the lines I try to automatically assign the members based on their meta. Can anybody help me with this please? Am I onto something here or I’m totally out here? I’m not really good at programming to be honest, just learning as I go (mostly by cut & paste).
Thanks in advance!
- The topic ‘Assign member type based on user meta’ is closed to new replies.