• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Custom user field callback, validate value 1.x

No permission to download
This is a skeleton for creating a callback for a custom user field. The callback is used to validate the value entered by the user. For example, if you are collecting some kind of ID that you need to check against another database.

The callback is specified when editing the custom field:

Screen shot 2012-01-12 at 10.51.04 PM.png


The skeleton contains this file which matches the callback name:

library/Callback/UserField.php

The example code only accepts a value of '123'. Otherwise it defines an error message and returns false. It's a very simple example for demonstration. You can use your own code inside of the validate() function:

Code:
<?php

class Callback_UserField
{
	public static function validate($field, &$value, &$error)
	{
		if ($value == '123')
		{
			return true;
		}
		else
		{
			$error = 'what no';
			return false;
		}
	}
}
Author
Jake Bunce
Downloads
89
First release
Last update
Rating
5.00 star(s) 2 ratings

More resources from Jake Bunce

Latest reviews

Thank you! This is just what I was looking for. Always great to see nifty tutorials like this one. Although I wish I could rate the resource without having to download it. (Since I'm only using my own class.)
Didn't know how to scrub profile details, followed this guide and it worked like a charm!