Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
4
Indexable
Never

add_shortcode('becomevendor', function(){
	ob_start();
		$vendor_id = get_current_user_id();
        if (marketking()->is_vendor_team_member()){
            $vendor_id = marketking()->get_team_member_parent();
        }

        // check if user is vendor
        $is_vendor = get_user_meta($vendor_id,'marketking_group', true);
        $is_approved = get_user_meta($vendor_id,'marketking_account_approved', true);
        if ($is_vendor === 'none' || empty($is_vendor) || ($is_approved === 'no')){

			$page = get_option('marketking_vendor_registration_page_setting');
			// if current page is become a vendor page, do not show it.
			global $post;
			if ($post->ID !== intval($page)){
				?>
				<p id="marketking_become_vendor_link_myaccount">
					<a href="<?php echo esc_attr(get_permalink($page)); ?>"><?php esc_html_e('Become a Vendor','marketking-multivendor-marketplace-for-woocommerce');?></a>
				</p>
				<?php
			}
		} else {
			?>
			<a href="<?php echo esc_attr(get_page_link(apply_filters( 'wpml_object_id', get_option( 'marketking_vendordash_page_setting', 'disabled' ), 'post' , true)));?>" class="marketking_go_vendor_dashboard_link"><button class="marketking_go_vendor_dashboard_button"><?php esc_html_e('Go to the Vendor Dashboard', 'marketking-multivendor-marketplace-for-woocommerce'); ?></button></a>
			<?php
		}

	return ob_get_clean();
});