WordPress User Pages (part 2)

-Update- While most of this is out dated as per line numbers and such, you can still get the basic idea on changes that need made.

See Part1 Creating WordPress User Pages


The first things we needed were the plugins, we needed something to help with the profile page but also the new users we would be getting. Scott was able to find Register Plus to enhance the registration page, not only can you add your logo and disclaimer but this allowed for extra defined fields which became very important later in the process. For the actual profile page we used Profiler, this gave us a list of users, each their own profile page and something to work off of to add the extras for each user.
Lets get into some code, but first, save yourself some headaches and download notepad++, you may think it’s easier to edit pages through wordpress itself but it’s not, with code highlighting, search and other extras notepad++ is a life saver and it’s free!
Install both profiler and Register Plus, configure and now we’re ready for changes. As I had said we want Twitter, Youtube and Flickr all on our user pages so we need a way to know how to get to each users data, So lets ask them when they are setting up their profile. In Register Plus, toward the bottom you’ll see User Defined Fields, these will create spots in the database to hold the users accounts, since all these services allow outside sites to see and use their product we don’t need a password, just their account name or what they want to point to.
Add 4 User Defined Fields all with a check in “Add Profile Field”, I called mine twitter, video, flickrID and flickrset. Save the changes. Now when you go into the edit your profile page you’ll see these 4 fields added, problem is there are no instructions, (what does video what in the blank field). Before adding the instructions, lets go into how we are pulling the services for the profile:
Twitter:
There is a javascript on twitter that will allow you to pull the last (how ever many you want) twitters from the site and place them on your site, all you need is the username. (code will be shown later)

Youtube
When looking at a youtube page, they have code to embed the video on your site, if you look at the embed code it’s always the same except for the video code, this code is shown in the address bar right after http://www.youtube.com/v/###########, the ##’s is the video code we need from each user.

Flickr
Flickr is a bit tougher, all users are given a user name but flickr really runs off of userid’s, so we need a userid and a setid from each person to find the exact set of images they’d like to show. We will also be using a 3rd party flash app to show a small gallery.

Adding the instructions for each, the code loops through your defined fields, so to add the correct instruction to each we need to watch for each field.
In register-plus.php (in the register plus plugin directory) around line 1366 or do a search for

$value = get_usermeta( $user_ID, $id );

The code you’ll see right after it is: (yes I know some of this runs off the side of the page)
————————————————–

?>		
<tr>
<th><label for="<?php echo $id;?>"><?php echo $v['label'];?>:</label></th>
<td><input type="text" name="<?php echo $id;?>" id="<?php echo $id;?>" value="<?php echo $value;?>"  /></td>
</tr>      
<?php 
					
}

————————————————–

We want to change this so under each field it will show instructions, so change the above code to: (remember always make a backup)
————————————————–

?>		
<tr>
<th><label for="<?php echo $id;?>"><?php echo $v['label'];?>:</label></th>
<td><input type="text" name="<?php echo $id;?>" id="<?php echo $id;?>" value="<?php echo $value;?>"  />

<?php

switch ($id) {

case "video":
echo "<br /><b>For Video -Only add what comes after v=, so  for http://www.youtube.com/watch?v=TYLeFroei9c,  input TYLeFroei9c</b></td></tr>";
break;

case "twitter":
echo "<br /><b>Your Twitter becomes a Trail Report, send from your cell phone</b></td></tr>";
break;

case "flickrid":
echo '<br /><b>Visit <a href="http://idgettr.com/" target="_blank">idGettr</a> to find your FlickrID</b>';
echo '<br /><b>Also visit <a href="http://www.flickr.com/account/prefs/optout/?from=privacy" target="_blank">Your Flikr Account</a> and uncheck "Hide me from searches?"</b></td></tr>';
break;

case "flickrset":
echo "<br /><b>Choose one of your sets and copy the numbers after /sets/ in the address bar</b>";
echo "<br /><b>Example: http://www.flickr.com/photos/richandsteph/sets/72157594346344597/, input 72157594346344597</b></td></tr>";
break;

}
}

————————————————–

Your Edit Profile Page will now show the following

Click image to enlarge
In part 3 we’ll get into changing the code on the profiler page to show our images and such.

Technorati Tags: , , , , , , ,

     

2 Comments to “WordPress User Pages (part 2)”

  1. […] you’ve missed them read Part1 and Part2. So in part2 we changed the code to the Register Plus plugin to allow for instructions for our […]

  2. […] Read Part2 and Part3, Finished Product is at Thebackpacker.tv Profile Pages I’ve spent the last couple […]


Leave a Reply