More input option at registration
-
Constant Pligger
More input option at registration
Hi guys! How could i add some extra inputs at registration, like his facebook profile or twitter.Basically i want to add 2 more input boxes in registration form one for twitter and one for facebook, and to store the input in the database.
-
Constant Pligger
This shouldn't be too difficult too add.
Add the two new fields to your database (users table).
Add the HTML to include the two additional form fields to the register_center.tpl page
You will then need to edit register.php and the insert query that is used for adding a new user.
I don't have the exact details, but if I have time today I may be able to post them. You may be better off adding this to the profile page though since adding more requirements / fields to the registration may cause people to not be interested in registering on your website.
-
Pligg Developer
I agree with urbn.
Adding the fields to the profile will be much easier and make more sense to the user..
In fact Pligg comes with a helper module called "Profile extra fields"
Helper modules are generally libraries and functions that other modules can tap into.
An example of a module that requires the profile extra fields module be activated is the Lattitude module.
-
Constant Pligger
Thank you all for your response.These fileds will only appear for users who register with facebook/twitter or openID because the fields will auto fill in with details .
-
Constant Pligger
Not sure if you are using a module of some type or not but if the fields in the database do not exist you will need to add them manually.
Not sure if it stores the facebook email, username, or user URL, or the twitter ID, username, or URL but you could add the following tables (as an example)
user_facebook, varchar 150 (should be big enough for URL, email, or ID)
user_twitter, varchar 150 (should be big enough for URL, email, or ID)
Next in your register_center.tpl add:
<input type="hidden" id="reg_twitter" name="reg_twitter" value="__THE_VALUE__" />
<input type="hidden" id="reg_facebook" name="reg_facebook" value="__THE_VALUE__" />
Not sure how you are getting the values, but they should replace the __THE_VALUE__ for each hidden form field.
This next part is un-tested but should give you an idea of what to do and where to start.
Edit /libs/user.php
Find function Create(){ (around line 49)
REPLACE:
if ($db->query("INSERT IGNORE INTO " . table_users . " (user_login, user_email, user_pass, user_date, user_ip,user_categories) VALUES ('".$this->username."', '".$this->email."', '".$saltedpass."', now(), '".$userip."', '')")) {
WITH:
if ($db->query("INSERT IGNORE INTO " . table_users . " (user_login, user_email, user_pass, user_date, user_ip,user_categories, user_twitter, user_facebook) VALUES ('".$this->username."', '".$this->email."', '".$saltedpass."', now(), '".$userip."', '','".$this->twitter."','".$this->facebook."')")) {
Open /register.php
FIND:
function register_add_user($username, $email, $password, $password2){
And REPLACE with:
$twitter = sanitize($_POST["reg_twitter"], 3);
$facebook = sanitize($_POST["reg_facebook"], 3);
function register_add_user($username, $email, $password, $password2, $twitter, $facebook){
What this SHOULD do (again not fully tested) is the following.
On the register there are 2 new hidden fields, 1 for facebook and 1 for twitter.
When the user submits the page the function register_add_user is called which passes the normal creation values AND the two new form fields to the Create class that does the user insert.
This may not be the cleanest way to do this, but it should get you 90% of the way to doing this.
-
Constant Pligger
Thanks a million!Your the man!Works perfectly.
-
Constant Pligger
Ok finally im almost done, but i still have a problem.When the user is logged in with facebook it stores the username, pasword, email and avatar.The problem is i can`t fix the avatar.The link from facebook to the avatar is stored in the database, but id doesnt show it in the profile.Does Pligg show only local stored avatar?Is there any way to fix that?This is how a link to the avatar looks like: http://profile.ak.fbcdn.net/hprofile..._6499287_n.jpg
Thank you!
-
Constant Pligger
My guess is it has something to do with how pligg handles the small and large avatar images.
With my system it does:
<span id="ls_avatar-large"><img src="{$Avatar_ImgLarge}" alt="Avatar"/></span>
<span id="ls_avatar-small"><img src="{$Avatar_ImgSmall}" alt="Avatar"/></span>
Again I'm not sure if you are using a module or not but with my base system for Avatar_imgSmall it simply looks to see if user_avatar_source is useruploaded. If it is it just adds 15_username.png or for large 30_username.png.
If you rightclick on the image is the image url something like 15_http://profile etc etc?
I haven't even looked at the avatar code but from all the complains I have gotten from users it is something I will need to modify and fix.
-
Constant Pligger
Actually i thought that the avatar is stored in pligg_users table at user_avatar_source .But in user_avatar_source is stored only the words "useruploaded" .How could i show an external avatar?How is there a way to save it from facebook to local automatically?The avatar looks like username_30.jpg and username_15.jpg
-
Constant Pligger
Well you will run into a couple of problems I'm guessing.
When a user adds an image an image pligg converts the origional and makes 2 copies, 15_username and 30_username (or which ever sizes you choose). So it uploads the image, converts the image type / size 2 different times. It then updates the database with "useruploaded". Then one the image is displayed the image URL is simply created by adding 15_ (or 30_ depeding on small or large) and username. So 15_urbn.png. It than adds on the avatar upload path (avatar/user_uploaded).
Now your BEST approach would be when the user is created would be to copy their image to the server and run it though the function the current system. This could be very easy or very difficult depending on how it is written. I've never looked at it so I'm going to guess it would be very difficult. But this would be best as you are not doing anything hackish.
The other option which would be a hack is to instead when the user is created set the user_avatar_source to something like "userfacebook" or "usertwitter". Then include a new record in the table like user_avatar_path which would be the full path to the users image (http://profile.facebook, etc etc).
The downside with this approach would be everytime the page loads the image would have to be requested from facebook, the image would break once deleted, you would have limited control to display size, and file size could be pretty large.
That being said the first approach would be your best option but could be very difficult to achive.
Similar Threads
-
By idanshechter in forum Questions & Comments
Replies: 1
Last Post: 09-22-2009, 09:49 AM
-
By Lorenzo in forum Questions & Comments
Replies: 1
Last Post: 06-24-2009, 08:28 PM
-
By swambala in forum Questions & Comments
Replies: 1
Last Post: 05-03-2007, 07:43 AM
-
By ryukenden in forum Questions & Comments
Replies: 1
Last Post: 04-30-2007, 02:24 PM
-
By en3r0 in forum Questions & Comments
Replies: 0
Last Post: 02-26-2007, 02:25 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules