FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » How to write a custom field check plugin (validate_custom_fields CUSTOM_FIELD_VALIDATE)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: How to write a custom field check plugin [message #168550 is a reply to message #168549] Mon, 20 May 2013 18:28 Go to previous message
Atomicrun is currently offline  Atomicrun   Sweden
Messages: 54
Registered: November 2010
Location: Lund
Karma:
Member
It seems that the caller send an extra parameter $err, and that
the error-string is truncated into one character.
The OK response is zero.
<?php
plugin_add_hook( 'CUSTOM_FIELD_VALIDATE', 'plugin_custom_field_validator');

function plugin_custom_field_validator( $array) 
{
   list( $err, $field_id, $field_name, $field_value) = $array;
   if ( $field_name == 'City')
   {
      $f_test = strtolower( trim( $field_value));
      if ( $f_test == 'city' || $f_test == 'yes')
      {
         return 'ERROR';
      }
   }
   return 0;
}

function custom_field_validator_info() 
{
    return array( 'name' => 'Custom Field Validator',
                  'desc' => 'Validate custom profile fields.',
                  'version' => '1.0');
}
?> 
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Just started working with FUD Forum
Next Topic: Referrals for someone to install for me
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 15:50:30 GMT 2024

Total time taken to generate the page: 0.04286 seconds