View Full Version : User profile field that can parse links
Brent H
10-27-2007, 08:09 PM
I'm trying to find a way for a custom user profile field to parse links. You could have a multiline textbox, and on each line the user would enter a URL which would be turned into a link after submission.
Anyone have any ideas?
Analogpoint
10-27-2007, 09:12 PM
Create a plugin on the member_customfields hook, and turn the urls into links. Where 6 is the profile field ID.
if ($profilefield['value'] != '' AND $profilefield[profilefieldid] == 6)
{
$links = explode ("\n", $profilefield['value']);
$output = array();
foreach ($links as $link)
{
$link = trim($link);
if (!empty($link))
{
$output[] = '<a href="' . $link . '">' . $link . '</a>';
}
}
$profilefield['value'] = implode('<br />', $output);
}
Brent H
10-27-2007, 09:35 PM
When I enable that plugin, the field I'm applying it to doesn't show up.
My field ID is 9, and this is what I have for the plugin:
if ($profilefield['value'] != '' AND $profilefield[profilefieldid] == 9)
{
$links = explode ("\n", $profilefield['value']);
$output = array();
foreach ($links as $link)
{
$link = trim($link);
if (!empty($link))
{
$ouput[] = '<a href="' . $link . '">' . $link . '</a>';
}
}
$profilefield['value'] = implode('<br />', $output);
}
I've tried it on a multiline text box and a single line text box; both are displaying nothing when enabled, and only the plain text when disabled. What am I doing wrong?
Analogpoint
10-27-2007, 09:57 PM
I had a typo in the code. There is a 't' missing from the word 'output' in the if block in the foreach loop. :(
Brent H
10-27-2007, 10:28 PM
Excellent, it works beautifully. Thank you very much!
jacobi
09-26-2008, 12:05 PM
This is awesome! Thank you.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.