Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Forum: Plugins
    In reply to: Plugin development, install

    You need to wrap the above code with the following if statement…

    if(!function_exists("rb_install")){
        function rb_install() {
    	global $wpdb;
    
    	//first check to see if the DB table already exists
    	$tableName = $wpdb->prefix . "rusty_beard";
    
    	if($wpdb->getvar("SHOW TABLES LIKE '" . $tableName . "'") != $tableName) {
    		//create DB tables
    		$install = "CREATE TABLE " . $tableName . "(
    				field_id  KEY INT NOT NULL AUTO_INCREMENT,
    				field_name VARCHAR(50),
    				field_type VARCHAR(50),
    				field_default VARCHAR(240),
    				field_required INT,
    				field_label VARCHAR(240)
    				field_order INT)";
    
    		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    
    		dbDelta($install);
    
    		//add version to DB
    		add_option("rb_version", $rbVersion);
    
    	}
        }
    
        //install the plugin
        register_activation_hook(__FILE__, 'rb_install');
    }

    I recently had the same issue when I tried changing the prefix of my tables manually. Luckily, I kept the original tables in tact while I tried to make this change. Everything was working fine for me with the exception of being able to edit both old and new posts/pages.

    I tried the security fix referenced above and it didn’t work for me. But, when I reverted back to the original prefix everything was working. My guess is that I missed something in the _options table that needed to be renamed from the old prefix to the new one.

    I’m not sure if you guys are having the same problem, but I thought I’d let you know about what happened to me. If I find a definitive solution (i.e. which option I missed or which database value needed to be changed), I’ll let you know.

    Hope that helps some.

Viewing 2 replies - 1 through 2 (of 2 total)