Go Back   Pligg CMS Forum > Pligg Development > Pligg Modules

Reply
 
LinkBack Thread Tools
Extended User Profile v0.1 - Almost Done, Need Help Details »»
Extended User Profile v0.1 - Almost Done, Need Help
Version: , by gen3ric (Constant Pligger) gen3ric is offline
Developer Last Online: Aug 2008 Show Printable Version Email this Page

Version: Unknown Rating: (2 votes - 4.00 average)
Released: 01-08-2008 Last Update: Never Installs: 0
 
No support by the author.

I'm really close to releasing my first module that makes it easier to add extra fields to a user's profile. The module installs fine, stores data, users can edit the extra profile fields by clicking the "Modify" link and the modifications save to the database fine, but I just can't quite get the data retrieved and displayed in the profile view.

I'd appreciate it if someone with a little more experience take a look at what I have so far and lend a hand.

Download Now

File Type: zip profiles.zip (4.9 KB, 101 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22 (permalink)  
Old 02-10-2008, 09:56 AM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
Thanks: 25
Thanked 17 Times in 11 Posts
Need a simple explanation

You guys all seem to find this easy to understand, by I need it explained to me real simple.

1. You say it allows you to add custom fields, but when you enable the module, go to your profile and click modify, there all already loads of new fields there. So shouldn't we be removing fields instead, and how do you do this? All I'd like is a field for a user introduction.

2. I would then assume that after you've removed the fields you don't need, you then add redwine's code for the remaining fields?

You see how confused I am? Can anyone fill in these blanks?

1. Upload profiles folder into modules folder and enable through Admin module management
2. ???
3. ???
4. Follow redwine's instructions on this thread.
5. ???
Reply With Quote
  #23 (permalink)  
Old 02-10-2008, 01:57 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 217
Thanks: 20
Thanked 102 Times in 65 Posts
Follow these steps

To add fields to the registration, you have to do the following:
1.Define the fields you want to add
2.Create the fields in the users table
3.Modify /templates/yget/register_step_1.tpl or register_center.tpl in 9.9.0
4.Modify /libs/user.php
5.Modify /register.php
6.modify /templates/yget/user_center.tpl
7./templates/yget/profile_center.tpl
8./profile.php
For instance, you want to add a textarea for the user to add a bio and a field where they can specify their interests:

Open your database and run this sql code from the users table:

To Add the bio column (I am assigning a TEXT type to hold a long text):

Note: substitute pligg_ with whatever prefix you have chosen during the installation.
Code:
ALTER TABLE `pligg_users`ADD COLUMN`user_bio` TEXT NULL

To add the interests field:
Code:
ALTER TABLE `pligg_users`ADD COLUMN`user_interests` varchar(128) NULL

Open /libs/lang.conf or /languages/lang_english.conf in 9.9.0 and add this under the “User Profile” section:
Code:
//<SECTION>USER PROFILE</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_User_Bio = "Biography"
 
//<SECTION>USER PROFILE</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_User_Interests = "Interests" 
And add this under the “Register” section:
Code:
 
//<SECTION>REGISTER</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Register_Bio = "Enter your Biography"
Save and close.
Open /templates/yget/register_step_1.tpl or register_center.tpl in 9.9.0:

Add this after the “Verify Password” code:
Code:
<br/><br/>
Code:
<b>{#PLIGG_Visual_Register_Bio#}:</b>
<br/><textarea name="bio" rows="10" cols="60" id="bio" WRAP=SOFT></textarea><br/><br/>
<b>{#PLIGG_Visual_User_Interests#}:</b><br />
<label class="req">{#PLIGG_Visual_User_Interests#}:</label>
             <br/><input type="text" id="interests" name="interests" value=""  class="textinput" size="20" tabindex="26" maxlength="128" /> 
Save and close.
Open /register.php

If you are NOT using 9.9.0
Go to function do_register1() section and anywhere after $username=$_POST['username']; the following:
Code:
$bio=$_POST['bio'];
$interests=$_POST['interests']; 
Go to //INSERT VALUES INTO DATABASE section and insert the text in blue as they appear in the code:

Code:
$sql1="INSERT INTO " . table_users . " (user_login, user_email, public_email, user_pass, user_date, user_ip, ………., user_bio, user_interests) VALUES ('$username', '$email', '$publicemail', '$saltedpass', now(), '$userip', ……., '$bio', '$interests')" ; 
If you ARE using 9.9.0

go to if(isset($_POST["regfrom"])) { and add the following in the case 'full': and case 'sidebar':

$bio = $db->escape(trim($_POST['bio']));

Few lines below in the if(isset(... section, add this:

if(isset($bio)){$main_smarty->assign('reg_bio', $bio);}

Change this code (changes are in red):

if($error == false){
register_add_user($username, $email, $password, $password2, $bio);
}


change (in red): the function register_add_user($username, $email, $password, $password2, $bio){

After $user = new User(); add:

$user->bio = $bio;

Save and close.

Up to here, we added the new fields and captured the data into the database.
Now we need to modify few files to get the data to the user profile.
Open /libs/user.php
Under the Class User { section, add this:

Code:
var $interests = ''; 
var $bio = ''; 
If you are using 9.9.0:

Locate function Create(){ and add this (in red) to the if ($db->query

, user_bio) VALUES

And in the query, add (in red)

'".$userip."', '".$this->bio."')")) {

Look for function store() { and insert this anywhere after $user_email = $db->escape($this->email);
Code:
$user_interests = $db->escape($this->interests);
$user_bio = $db->escape($this->bio); 
Go down few lines to where it starts with $sql .= " , user_login=
And insert the following right before the WHERE
Code:
, user_bio='$user_bio', user_interests='$user_interests' 
Go to function read() { and insert the following anywhere before the line that reads $this->read = true;

Code:
$this->bio = $user->user_bio;
$this->interests = $user->user_interests; 
Look for function fill_smarty($main_smarty, $stats = 1){
And insert this before the line that reads if($stats == 1){

Code:
$main_smarty->assign('user_interests', $this->interests);
$main_smarty->assign('user_bio', $this->bio); 
Save and close.
Open /templates/yget/user_center.tpl
Look for <div id="personal_info">
And insert the following anywhere you want them to appear in the profile:

Code:
{if $user_bio ne ""}
 <tr>
<td><strong>{#PLIGG_Visual_User_Bio#}:</strong></td>
             <td>{$user_bio}</td>
 </tr>
{/if}
 
{if $user_interests ne ""}
 <tr>
             <td><strong>{#PLIGG_Visual_User_Interests#}:</strong></td>
             <td>{$user_interests}</td>
 </tr>
{/if} 
Save and close.

Open /profile.php
Look for function show_profile() {
And insert the following before the line // pagename

Code:
$main_smarty->assign('user_interests', $user->interests);
$main_smarty->assign('user_bio', $user->bio); 
Look for function save_profile() {
And insert the following before the line // module system hook

Code:
$user->interests=cleanit($_POST['interests']);
$user->bio=cleanit($_POST['bio']); 
Save and close.

Open /templates/yget/profile_center.tpl
And insert this at the end of the first table before </table> Don’t forget to assign the tabindex.

Code:
<tr>
 <td><label class="req">{#PLIGG_Visual_User_Interests#}:</label>
             <input type="text" id="interests" name="interests" value="{$user_interests}"  class="textinput" size="30" tabindex="" maxlength="128" />
 </td>
 <td>&nbsp;</td>         
</tr>
<tr>
 <td><label class="req">{#PLIGG_Visual_User_Bio#}:</label>
<textarea name="bio" rows="10" cols="60" id="bio"  WRAP=SOFT>{$user_bio}</textarea>
 </td>
 <td>&nbsp;</td>         
</tr> 
Save and close
Et voila, you’re done!

Last edited by redwine; 02-14-2008 at 12:14 PM.
Reply With Quote
The Following 4 Users Say Thank You to redwine For This Useful Post:
  #24 (permalink)  
Old 02-10-2008, 06:37 PM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
Thanks: 25
Thanked 17 Times in 11 Posts
Thanks redwine.

So if I understand you correctly, the instructions in the profiles module should NOT be followed, i.e.

Quote:
...place {checkActionsTpl location="tpl_show_extra_profile"} where you want the extended fields to display in user_center.tpl
This is what confused me from the start. Could the module be updated with the correct instructions or a link to this thread?
Reply With Quote
  #25 (permalink)  
Old 02-10-2008, 09:27 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 217
Thanks: 20
Thanked 102 Times in 65 Posts
I just made it easier for you to implement!

Quote:
Originally Posted by longcountdown View Post
Thanks redwine.

So if I understand you correctly, the instructions in the profiles module should NOT be followed, i.e.



This is what confused me from the start. Could the module be updated with the correct instructions or a link to this thread?
No, this is not what I want you to understand. I just made it easier for you to implement, because you said that you only want to add one field so I gave you the instructions from A to Z, the easy way instead confusing you with all the extra fields that the module adds. It is also to note that you can add as many fields as you wish by simply following the same process. I hope that I was able to help!

Cheers!
Reply With Quote
  #26 (permalink)  
Old 02-11-2008, 02:14 AM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
Thanks: 25
Thanked 17 Times in 11 Posts
Quote:
Originally Posted by redwine View Post
I just made it easier for you to implement
Great! Works perfectly! Thanks again
Reply With Quote
  #27 (permalink)  
Old 02-14-2008, 06:37 AM
jacksparrow's Avatar
Pligg Donor
Pligg Version: 9.9.0
 
Join Date: Feb 2007
Location: NJ
Posts: 32
Thanks: 10
Thanked 1 Time in 1 Post
Question help for 9.9 again

Hi Redwine...

Cannot do the register.php part in ver 9.9 ... the code is different insted of Post it is add user... pls let me know where to add the codes.

Cheers.

Jack.
Reply With Quote
  #28 (permalink)  
Old 02-14-2008, 07:43 AM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 217
Thanks: 20
Thanked 102 Times in 65 Posts
Preparing Modifications for 9.9

Quote:
Originally Posted by jacksparrow View Post
Hi Redwine...

Cannot do the register.php part in ver 9.9 ... the code is different insted of Post it is add user... pls let me know where to add the codes.

Cheers.

Jack.
Thanks again jack, I am looking now to the needed modifications for 9.9. I'll post it in a while.
Reply With Quote
  #29 (permalink)  
Old 02-14-2008, 12:19 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 217
Thanks: 20
Thanked 102 Times in 65 Posts
Instructions include 9.9.0

I have modified my post to include instructions for version 9.9.0.

Extended User Profile v0.1 - Almost Done, Need Help
Reply With Quote
The Following User Says Thank You to redwine For This Useful Post:
  #30 (permalink)  
Old 02-18-2008, 06:34 AM
jacksparrow's Avatar
Pligg Donor
Pligg Version: 9.9.0
 
Join Date: Feb 2007
Location: NJ
Posts: 32
Thanks: 10
Thanked 1 Time in 1 Post
Perfect - hats off to redwine - a rare vintage quality

Just implemented

Jack
Reply With Quote
  #31 (permalink)  
Old 07-06-2008, 11:57 AM
catchpen's Avatar
Pligg Donor
 
Join Date: Jan 2008
Posts: 208
Thanks: 30
Thanked 18 Times in 13 Posts
Quote:
Originally Posted by gen3ric View Post
This mod allows you to add unlimited custom fields to the user profile section. Unfortunately, it involved more manual work than I had originally hoped and I don't know enough PHP code to get it packaged in a complete module, but if you follow Redwine's explanation, you can get it working pretty easily.

I am currently using it to allow users to add their usernames to various other social media sites as well as an interests field and a short bio.

Demo: Design Float
I looked at a few profiles there nothing different. Can you post one of a member that is participating in this or did you remove the mod off the site?

Edit: signed up and seen my own profile. This could be used more radically I suppose

Last edited by catchpen; 07-15-2008 at 01:20 AM.
Reply With Quote
Reply

Thread Tools
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
Newline ability needed for a field in user profile rossoonline General Help 0 09-18-2007 05:23 PM
How to link Extra fields in Profile to pull information from user table in database pliggnewbie Pligg Mods 0 04-12-2007 12:59 AM
Custom user profile fields revolver Suggestions 2 12-05-2006 08:52 PM
How can I add new fields to user profile gragland General Help 0 07-17-2006 11:03 PM
[bug fix] discarded stories are dipalyed in user profile gragland Bug Report 0 07-04-2006 04:18 PM


Search Engine Friendly URLs by vBSEO 3.2.0