PDA

View Full Version : str_replace member field


Bilderback
09-25-2008, 03:11 AM
I've had all sorts of problems trying to convert a members profile field to URL.
My example is a MySpace field which allows a member to enter their account ID.
What I am trying to turn the field entry into a hyperlink shown in the users profile page.
Example:
User enters MySpace ID of 123456
I want to create a plugin to replace the field so when viewing their profile, it shows as:
http://www.myspace.com/123456

Below is what I have been trying but I am definitely going wrong somewhere.
Template: profile_myspace
MySpace Field: 5
Hook: member_customfields

global $vbulletin;
if ($vbulletin->options['profilefieldid==5'])
{
eval('$profilefield[field5] = "' . fetch_template('profile_myspace') . '";');
}


Can anyone point me in the right direction?
Thanks

calorie
09-25-2008, 04:02 AM
Untested plugin for member_customfields hook:

if ($profilefield['profilefieldid'] == 5)
{
$profilefield['value'] = '<a href="http://www.myspace.com/' . intval($profilefield['value']) . '">MySpace Page</a>';
}

Bilderback
09-25-2008, 01:59 PM
Thanks. The above code didnt return the url correctly but it set me straight.
In your example, the url is returned with http://www.myspace.com/0
Which made me realize the value was being overwritten with the plugin.
Adding a new value solved the problem and works.

if ($profilefield['profilefieldid'] == 5)
{
$myspace_field = $profilefield['value'];
$profilefield['value'] = '<a href="http://www.myspace.com/' . intval($myspace_field) . '">MySpace Page</a>';
}


The reason I added a variable is that I cant remember the vbcode for a members profile field. :erm:
Thanks Calorie

I'm just wondering now if I can do this twice for 2 different profile fields within the same plugin.
I'm guessing that functions will need written as not to confuse $profilefield[value']