Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums How To Integrating with existing member (user) database
Ccs9623
Posted on 21 Nov 2010, 03:55:54

Access: Member
Total Posts: 16
Joined: 2009-07-10

Chris. In an existing 'members only' site, my user's have already created an account within my site. I'm trying to avoid having them create multiple accounts for things like this news system, discussion forum, etc.

* User's are not permitted to create articles, only post comments.
* I will never need to display or use User Email addresses on the site.
* User's will not maintain a personal profile or anything like that.

The only thing I really want is to save the user's name when they post a comment. I save this name as a session variable so I was thinking I could grab it from there somehow.

With the discussion forum I am using, I automatically create a user account in their table when a member joins, and then bypass the forum's login process so users are 'automatically' logged in. That took quite a bit of program mods. I'm hoping not to have to do the same with N-13, but I can if necessary.

How would you suggest I go about this, keeping in mind that I really only need to track the user's name on any comments they make?

TIA.
--Joe
#3058
Chris
Posted on 21 Nov 2010, 04:39:48

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

Probably the easiest way to go about this would be instead of creating additional accounts within the news system that match the accounts your users already have with your members system, grab the username from the session variable for your members system then pass it to the news system to use in the comments form when the user wants to post a comment.

The way I would do this is

Code:
<?php
// grab the username from your members system and store it as a new variable
// change to match the correct session variable
$commentsusername = $_SESSION['member_system_username'];


// the news system checks if you're logged in, if you are it then grabs you're
// username which is stored in $_SESSION['name']
// we set that manually here so that it matches the username of your member system

$_SESSION['name'] = $commentsusername;
include 
'news/index.php';
?>


You'll need to make one small edit to news/functions.php, on line 438~ you'll see this

Code:
$tmpname    = $langmsg['news'][47];


Comment that out by placing a # in front so it looks like this

Code:
#$tmpname    = $langmsg['news'][47];


Now all you need to do is edit the Comments Form within the news system template, Options > Template > Edit whichever one you're using > Comments Form

Make the username field hidden by adding a style attribute to it, style="display: none"

Basically what we've done is pass the username from your members system to the news system, which then uses that for the comments form and automatically places it within the username input field, made the input field hidden so the user doesn't need to enter it themselves.

It's like 4:39am right now so I hope this makes sense, I quickly tested it and it seemed to work but I may have overlooked something. Any problems let me know.
#3059
Last edited by Chris at 2010-11-21 04:40:36 Reason:
Network-13.com © 2013