Home / Admin / WC Vendors Activate All Inactive Vendors
Duplicate Snippet

Embed Snippet on Your Site

WC Vendors Activate All Inactive Vendors

Activates all inactive Vendor Stores in a WC Vendors Marketplace.

NOTE: To be ran once.

Code Preview
php
<?php
/** Activates all Vendor Stores **/
function wcv_activate_all_vendors() {
	global $wpdb;
	$vendors = get_users( array( 'fields' => array( 'ID' ), 'role' => 'Vendor' ) );
	$meta_key = '_wcv_vendor_status';
	foreach($vendors as $vendor){
		$wpdb->query($wpdb->prepare("UPDATE wp_usermeta SET meta_value='active' WHERE user_id=$vendor->ID AND (meta_key='$meta_key' AND meta_value='inactive')"));
	}
}
/** Activate all Vendor Stores after WordPress has finished loading [but before any headers are sent] **/
add_action('init', 'wcv_activate_all_vendors');

Comments

Add a Comment