WordPress Automatic Update Issues

When trying to use WordPress automatic update I got this error ‘Error: There was an error connecting to the server, Please verify the settings are correct.’, after trying multiple attempts to rid myself of the problem I had a eureka moment. I thought to myself, “what if it Apache wasn’t seeing the right permissions of the folders?”, and low and behold that was the problem.

Apache was expecting the owner of the folders in the document root to be www-data, I figured this is for some form of security purposes.

How I got rid of the problem

I got rid of the problem by changing the group and owner of my WordPress install folder in apache root to www-data by executing the following command:

cd /yourwordpress_dir/
sudo chown -R www-data:www-data *

Migrating Cforms 2 to Production Server

Cforms II is one of the most popular plug-ins considered by WordPress. I recently started using this plug-in for the contact form on any website that I create and it works like a charm. The only problem arise when you want to migrate your local development install to your production server. Here I am presenting a nice little script that I put together to help with fixing the form references after migration.

The Problem

When you migrate your cforms plugin from server to server, cform apparently keeps reference to the initial install which for me caused a lot of problem. For instance, when the website was loading I realise that a file was being referenced from my local server. huh!!! I was curious which plugin was doing this and went straight to the database only to find out that the culprit (with no fingers pointing) was cforms.

These are the references that it keeps:

$cformsSettings['global']['cforms_root']
$cformsSettings['global']['tinyURI']
$cformsSettings['global']['cforms_root_dir']
$cformsSettings['global']['cforms_upload_dir']

Because the cforms data is being saved in the database as serialised data changing these from the database would cause the data to be corrupted and in some instances cause your cforms install useless.

For me, I had both problems, I initially tried to update the data from the database and it got corrupted and I tried using the methods prescribed by cforms to fix this problem but that didn’t work. Cforms method is to disable and enable the plugin or edit the data in the little form that the corrupt data page gives you.

Remember, always backup your wordpress install, both database and files before messing around, especially in production environments.

Also, in cforms, go to global settings and backup all settings.

The Solution to Updating the References

After finding that the problem was with cforms I went into cforms code and found what they were doing and here is the final result. Use this method if you have moved over your installation and want to update the references to your production server.

/**
 * Updates cforms data to reflect the current host that it is on
 *
 * @return
 */
function update_cforms_data() {
	if($cformsSettings['global']['cforms_root'] != WP_PLUGIN_URL . '/cforms') :
		$cformsSettings['global']['cforms_root'] = WP_PLUGIN_URL . '/cforms';
		update_option('cforms_settings',$cformsSettings);
	endif;

	if($cformsSettings['global']['tinyURI'] != get_option('siteurl') . '/wp-includes/js/tinymce') :
		$cformsSettings['global']['tinyURI'] = get_option('siteurl') . '/wp-includes/js/tinymce';
		update_option('cforms_settings',$cformsSettings);
	endif;

	if($cformsSettings['global']['cforms_root_dir'] != WP_PLUGIN_DIR . '/cforms') :
		$cformsSettings['global']['cforms_root_dir'] = WP_PLUGIN_DIR . '/cforms';
		update_option('cforms_settings',$cformsSettings);
	endif;

	if($cformsSettings['global']['cforms_upload_dir'] != WP_PLUGIN_DIR . '/cforms$#$') :
		$cformsSettings['global']['cforms_upload_dir'] = WP_PLUGIN_DIR . '/cforms$#$';
		update_option('cforms_settings',$cformsSettings);
	endif;
}

The Solution to Remove Cforms Totally and Reinstall

Use this method to totally remove cforms data from the database, especially if cforms constantly reports that its data is corrupt and doesn’t give you the option to remove it.

$wpdb->query("DELETE FROM `$wpdb->options` WHERE option_name LIKE 'cforms%'");
$wpdb->query("DROP TABLE IF EXISTS $wpdb->cformssubmissions");
$wpdb->query("DROP TABLE IF EXISTS $wpdb->cformsdata");

Remember to backup your website before messing around.

  • WordPress version: WordPress 2.8.1
  • Cforms version: Cforms 2 10.5.2