PDA

View Full Version : Users name to post as "Guest"


h2ojunkie
12-05-2008, 03:51 AM
How hard would it be to add support to allow the Users name to post as field to be Guest or userid 0?

I tried the following, but it just ended up posting the article under the userid I was logged in as

if ($this->settings['ugs_able_to_post_as_other_users'])
{
if (is_member_of($this->vb->userinfo, $this->settings['ugs_able_to_post_as_other_users']))
{
if ($this->vb->GPC['GARS_post_as'])
{
if ($this->vb->GPC['GARS_post_as'] == "Guest") { $postasid = 0; }
else {
$result = $this->db->query_first("SELECT userid FROM " . TABLE_PREFIX . "user WHERE
username ='" . $this->db->escape_string($this->vb->GPC['GARS_post_as']) . "'
");

if (!$result['userid'])
{
$errors[] = construct_phrase($this->vbphrase['GARS_err_no_user'],$this->vb->GPC['GARS_post_as']);
}
else
{
$postasid = intval($result['userid']);
}
}
}
}
}

Morgan
12-05-2008, 04:23 PM
Not sure, haven't done it, but you might run into a problem as guests have userid of zero and do not have an entry in the vB user table. You'd probably need to change more than that code, i.e., look for post_as_id for other locations in the code.

h2ojunkie
12-06-2008, 06:32 PM
I tried your suggestions and made a couple more edits to gars_class_core.php with no luck there either

$data = unserialize($result['data']);
if ($data['post_as_id'])
{
if ($data['post_as_id'] == 0) {
$username = "Unregistered";
} else {
$username = $this->db->query_first("SELECT username FROM " . TABLE_PREFIX . "user
WHERE userid = " . intval($data['post_as_id'])
);
}
}


It appears to be saving the data to gars>data:
a:5:{s:7:"post_as";s:12:"Unregistered";s:10:"post_as_id";i:0;s:6:"gal_id";N;s:12:"gal_keywords";s:0:"";s:8:"gal_text";s:0:"";}

But not so lucky with the thread and post tables.

Any suggestions for what I might be missing?


P.S. I changed to using "Unregistered" instead of "Guest"

Morgan
12-07-2008, 01:51 AM
The GARS post as another user feature was coded with the assumption that the other user is a member and not a guest. The are two ways that I see ATM to post as a guest. One is to sift through the code and make the necessary changes. As I haven't done this, the only way to really approach it would be to go through all the code and see what needs to be changed and where. The other way would be to create another member account and post under that user name, and then use a template conditional to change what gets displayed in the postbit based on the userid of the "guest" user account.

h2ojunkie
12-07-2008, 02:11 AM
The other way would be to create another member account and post under that user name, and then use a template conditional to change what gets displayed in the postbit based on the userid of the "guest" user account.

Hey!..that's a good idea. I'll do that.

Thanks!