<?php
/*
Plugin Name: Conditional Error Checking
Description: Perform different error checking based on existing field values
Version: 1.00
Requires at least: 2.02
*/

// register callbacks
addAction('record_save_errorchecking', 'conditionalErrorChecking', null, 2);

//
function conditionalErrorChecking($tableName, $recordExists) {
  if (@$tableName != 'news') { return; }  // skip all but target table/section

  // debug - uncoment to see form values on form save
  //die( showme($_REQUEST) );

  // for low priced items (under one dollar)
  if (@$_REQUEST['cost'] < 1) {
    if ( strlen(@$_REQUEST['title']) > 10) {
      die("Title must be less than 10 characters for low priced items!");
    }
  }

  // for higher prices items (over or equal to one dollar)
  if (@$_REQUEST['cost'] >= 1) {
    if ( strlen(@$_REQUEST['title']) < 25) {
      die("Title must be more than 25 characters for high priced items!");
    }
  }

  // end of function
}


?>
