Our Blog: The Archive

Aug25th

Comments Off

Greenwich Action for Voluntary Service Website Launch

Tags for post entry: Greenwich Action for Voluntary Service Website LaunchWritten by Jon Webb on September 25th, 2009, Posted in New Projects, News |

Tags for post entry: Greenwich Action for Voluntary Service Website Launch, , ,

We’re pleased to announce the launch of a new website for the Greenwich Action For Voluntary Service (GAVS), in association with Firefly Creative.

Our Role

greenwich-action-for-voluntary-service-home-page

Firefly approached us to provide the technical consultancy and build of the GAVS website, and when we saw the initial designs we knew that Firefly certainly pushed the design boundaries with an attractive translucent feel to the website. From design to complete content managed solution – we delivered a solution which allows GAVS to: update almost all content on the website; create new sections, and; optimise their website for search engines.

On-top of all this we also:

  1. Integrated Yahoo’s Upcoming Events service. This service drives their events management section, and allows GAVS to broadcast their events and training seminars to a wider, world-wide audience.
  2. Provided a custom, secure membership section which gives members of GAVS the ability to subscribe and download essential content. We gave the GAVS Editorial team the power to approve, suspend, delete and generally manage all their subscriptions.
  3. Provided key editorial control over various accessibility features, such as the “accesskey”, Allowing GAVS to meet their minimum requirements for accessibilty.

The site was delivered on time, and above spec.

About GAVS

GAVS exists to provide a strategic leadership role to support the development of voluntary, community and faith organisations, within the borough of Greenwich, London.

Visit the new website: Greenwich Action for Voluntary Service

Aug10th

Comments Off

Wordpress Tip – Turn off Allow Pings and Comments by Default

Tags for post entry: Wordpress Tip – Turn off Allow Pings and Comments by DefaultWritten by Jon Webb on September 10th, 2009, Posted in Wordpress |

Tags for post entry: Wordpress Tip – Turn off Allow Pings and Comments by Default

As part of my week long campaign to divulge some useful information about customising Wordpress into a decent Content Management Solution for small businesses I’ve got another top tip – however this is a developer related top tip and involved rummaging around in the database.

The tip

Today’s tip is about how you can turn off the “Allow comments on this post”, and “Allow trackbacks and pingbacks on this post” options by default on your Wordpress site.

Wordpress Discussion Defaults Tick Boxes

Wordpress Discussion Defaults Tick Boxes

The Solution

In the wordpress database, specifically the wp_options table, there are two options under the option_name column called:

  • default_comment_status
  • default_ping_status

If you run the following SQL query against your Wordpress database’ wp_options table:

select option_name, option_value from wp_options where option_name in('default_ping_status', 'default_comment_status');

It yields the following results:

+------------------------+--------------+
| option_name            | option_value |
+------------------------+--------------+
| default_comment_status | open         |
| default_ping_status    | open         |
+------------------------+--------------+

As you can see – the default is always set to allow comments and pings on all new pages and posts. Now, update the option_value column relating to the default_comment_status and the default_ping_status with the value closed. Now Wordpress will no longer allow new pages/blog posts to be saved with these options open to the world. See the following SQL command on how to achieve this.

Note: it’s always wise to backup before making this sort of update, and on a Wordpress MU installation you will want to add a WHERE clause so that you only target the wordpress site you intend to change these options for.

update wp_options set option_value='closed' where option_name in('default_ping_status', 'default_comment_status');

Tada!

Discussion Meta Box with Defaults set to off

Discussion Meta Box with Defaults set to off

See the Wordpress Options Reference documentation for further information.

Aug8th

Comments Off

Customising cforms2 – A wordpress plugin

Tags for post entry: Customising cforms2 – A wordpress pluginWritten by Jon Webb on September 8th, 2009, Posted in Wordpress |

Tags for post entry: Customising cforms2 – A wordpress plugin

As you may be aware I’m a firm supporter of using Wordpress on small websites as it gives web developers a quick and easy path to giving small businesses a cost effective web presence. But what happens when a Wordpress plugin only gets you 80% of the way there?

So today this blog post is about customising the excellent cformsII wordpress plugin which allows developers and end users alike to create fully featured contact and data capture forms within a Wordpress based website.

I’ve got a requirement where I use the cformsII plugin to create a membership registration form. The extra requirements for this registration form are that alongside the normal input checking for the form – I also need to check that an email address has not already been used within the Wordpress database for a user.

Unfortunately, cforms2 does not natively support this so I need to customise the plugin. To keep this customisation to a minimum I’m going to change the least amount of the cforms core to acheive the ability to validate this email address against the database.

Here goes, code examples follow along with some caveats:

  1. These code examples need basic understanding of PHP as to how and why things are done.
  2. Your cforms form must not be AJAX enabled – otherwise the validation routines do not work.
  3. You should always make a backup of your plugins directory before modifying any plugins

To start off with we need to change the cforms lib_validate.php which can be located in your ./wp-content/plugins/cforms/ directory of your wordpress installation. You need to go to approximately line 203 of this file, you’ll see following line of code around line 203:

$all_valid = $all_valid && $validations[$i+$off];

Directly above this line you’ll need to cut and paste the following code. This code instructs cforms to pass the form field data to your custom validation function. It also passes the results of the validations cforms has already performed on the field so that you can selectively choose to process the field again.

if(function_exists('cforms_custom_validation'))
{
    $result = cforms_custom_validation($input_name[1], $current_field, $field_type, $validations[$i+$off], $c_err[1]);
    $validations[$i+$off] = $result[0];
    if($result[0] == false)
    {
        $c_err[1] = $result[1];
        $err = 1;
    }
}

Next we need to make use of the code we’ve just inserted into the core of cforms2. To do this we need to create the following directory & file, or edit the file:

(wordpress installation root)/wp-content/plugins/cforms-custom/my-functions.php

and insert the following code:

function cforms_custom_validation($fieldId, $fieldValue, $fieldType, $existingResult, $existingError)
{
    // Create an array $returnValue which contains a default return value, this array is comprised
    // of the first element being the existing validation result so you can check if cforms has
    // already validated it as bad. The second element of the array is incase cforms has given
    // any custom error message which you may need to re-use.
    $returnValue = array($existingResult, $existingError);
    // Check two things before running the custom validation:
    // 1.) That cforms hasn't already marked this field as invalid, and;
    // 2.) Check the $fieldId passed is the one I want - this should be more robust, but suits my needs
    if($existingResult == true && $fieldId == 'Email address[id:user-email]')
    {
        //do custom validation
        $result = TonicUser::Exists($fieldValue);
        if($result->status == true)
        {
            //set the return value: the first element being false, as the validation failed. The second being 'Oops' which is your failure message.
            $returnValue = array(false, 'Your email address has already been used to register an organisation');
        }
    }
    return $returnValue;
}

You’ll see a comparison being made: $fieldId == ‘Email address[id:user-email]‘ . The ‘Email address[id:user-email]‘ part is directly related to the following screenshot. I hope the comments against the rest of the code are relatively self explanatory.

Screenshot showing the field id used in the code comparison

Screenshot showing the field id used in the code comparison

Hope that helps WP users.

Aug4th

Comments Off

Mac Usability

Tags for post entry: Mac UsabilityWritten by Jon Webb on September 4th, 2009, Posted in Random |

Tags for post entry: Mac Usability

Seriously! If the mac’s are supposedly better engineered than the rest of the competition – why do they put the close application (cmd + tab) keyboard shortcuts right next to switch window (cmd + tab) short cuts? As a heavy keyboard user, and one who is new to an Apple Mac and continues close his applications instead of switching windows it is highly irritating.

Answers on a postcard.

Aug3rd

Comments Off

Wordpress Post/Page Attributes Meta Box Missing

Tags for post entry: Wordpress Post/Page Attributes Meta Box MissingWritten by Jon Webb on September 3rd, 2009, Posted in Advice, Wordpress |

Tags for post entry: Wordpress Post/Page Attributes Meta Box Missing

As an avid wordpress developer – I was mildly annoyed when my ability to set the parent, order and template of a new/existing page disappeared. (see screenshot)

Wordpres Editor Showing Missing Metabox

Wordpres Editor Showing Missing Metabox

This particular part of the Wordpress admin area is called a meta box.

Now, I guessed that a plugin had some how hooked into the Wordpress internals and prevented this meta box from being displayed. So I disabled and removed all of the plugins from the wp-content/plugins directory. Still no joy!

Next I wondered if the box had actually been created but was being hidden in the HTML. To get around thisĀ  I cracked out Firebug, and sniffed to the offending element. As you can see – the content for the meta box was there, but was being hidden. As there were no active plugins running in wordpress I thought I was in for the long haul in bug finding duties.

Firebug - Desperately Seeking Solution

Firebug - Desperately Seeking Solution

Finally…. I thought, “maybe it’s set in the database somewhere”, so I took a full database export using the following command:
(bear with me I’m a bit of a command line freak – you could do all this with a graphical tool, and a quick text search)

mysqldump client_db > export.sql

and then

grep "hidden" -R ./export.sql | grep "parentdiv"

which bought me back the following clues through its matches & text.

INSERT INTO `gvxwp_usermeta` VALUES (1,1,'nickname','admin'),(2,1,'rich_editing','true'),(3,1,'comment_shortcuts','false'),(4,1,'admin_color','fresh'),(5,1,'gvxwp_capabilities','a:1:{s:13:\"administrator\";b:1;}'),(8,1,'gvxwp_usersettings','m0=o&m1=c&m2=c&m3=o&m4=c&m5=c&m6=c&m7=c&m8=o&hidetb=1&m9=c&m10=o&m11=o&m12=o&m13=o&m14=o&editor=tinymce'),(7,1,'gvxwp_user_level','10'),(9,1,'gvxwp_usersettingstime','1251978204'),(10,1,'gvxwp_autosave_draft_ids','a:34:{i:-1251323402;i:3;i:-1251323450;i:5;i:-1251367945;i:9;i:-1251369126;i:11;i:-1251369212;i:13;i:-1251369233;i:15;i:-1251369361;i:18;i:-1251369390;i:20;i:-1251369425;i:23;i:-1251372639;i:31;i:-1251473041;i:44;i:-1251473060;i:46;i:-1251473077;i:48;i:-1251473834;i:51;i:-1251574534;i:53;i:-1251574841;i:55;i:-1251574963;i:57;i:-1251575242;i:60;i:-1251575336;i:62;i:-1251575626;i:65;i:-1251575955;i:69;i:-1251580584;i:72;i:-1251581490;i:75;i:-1251812158;i:88;i:-1251815776;i:92;i:-1251817272;i:99;i:-1251818207;i:102;i:-1251821608;i:110;i:-1251821710;i:112;i:-1251821756;i:114;i:-1251821809;i:117;i:-1251876324;i:125;i:-1251883246;i:130;i:-1251981128;i:136;}'),(11,1,'plugins_last_view','all'),(12,1,'closedpostboxes_page','a:1:{i:0;s:12:\"revisionsdiv\";}'),(13,1,'metaboxhidden_page','a:4:{i:0;s:13:\"pageparentdiv\";i:1;s:13:\"pagecustomdiv\";i:2;s:20:\"pagecommentstatusdiv\";i:3;s:11:\"pageslugdiv\";}');

As you can see from that lot there are two special keywords: “pageparentdiv” which is the html id for the meta box which has been hidden; “metaboxhidden_page”, which is the value for a meta_key in the wp_postmeta mysql table.

To resolve my problem – all I needed to do using the above information was a quick

BEFORE DOING THE FOLLOWING, ENSURE YOU’VE BACKED UP YOUR ENTIRE WORDPRESS DATABASE AND FILES, IT MAY ALSO HAVE AN ADVERSE EFFECT ON ANY PLUGINS WHICH USE THIS INFORMATION.

mysql client_db;
delete from wp_postmeta where meta_key = 'metaboxhidden_page';

et voila! a working post attributes meta box

Fixed - The meta box returns

Fixed - The meta box returns