• Resolved Karan

    (@peeyooshk)


    Hello:

    We wish to remove the data from our hybrid store and make a standalone B2B store on another domain name. Although we were unable to find any method to delete all existing data from database related to b2bking before removing the plugin from our hybrid store.

    how to achieve this?

Viewing 1 replies (of 1 total)
  • Plugin Author WebWizards

    (@webwizardsdev)

    Hi Karan,
    Thank you for using our plugin,

    If you want to clear all existing B2BKing data from users, posts, products, settings, custom B2BKing posts, etc., you can run the following snippet once:

    // clear options
    	global $wpdb;
    	$plugin_options = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%b2bking%'" );
    	foreach( $plugin_options as $option ) {
    	    delete_option( $option->option_name );
    	}
    
    	// clear all custom posts
    	$post_types = array('b2bking_custom_role', 'b2bking_custom_field', 'b2bking_group', 'b2bking_rule', 'b2bking_offer', 'b2bking_conversation');
    	foreach ($post_types as $type){
    		$allposts= get_posts( array('post_type'=> $type,'numberposts'=>-1) );
    		foreach ($allposts as $eachpost) {
    			wp_delete_post( $eachpost->ID, true );
    		}
    	}
    
    	// clear user metadata
    	$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '%b2bking%'");
    
    	// clear product metadata
    	$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '%b2bking%'");
    
    
Viewing 1 replies (of 1 total)
  • The topic ‘Remove all data related to plugin as cleanly as possible’ is closed to new replies.