PDA

View Full Version : Truncating the display of a user profile field in postbit


imageconstrux
01-03-2008, 01:34 AM
I have a custom user profile field that when registering, needs to be about 40 characters long, but when I display it in the postbit $post[field18], I need to truncate it to 7 characters.

How would I go about doing that?

Opserty
01-03-2008, 09:39 AM
You'd have to create a Plugin with a hook location of something like postbit_display or postbit_process. Then use PHP code like this:

$post['field18'] = substr($post['field18'], 0, 7);

// If you want to add the trailing dots then use the line below instead:
$post['field18'] = substr($post['field18'], 0, 7) . '...';

imageconstrux
01-03-2008, 12:07 PM
Wow - worked like a charm. postbit_display_start was the hook location that did the trick.

Thanks for your help!