Resource icon

Unmaintained 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.webp


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
95
Views
1,405
First release
Last update

Ratings

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!
Top Bottom