2013-03-06, 01:07 PM
Pages: 1 2
2013-03-06, 02:18 PM
Be clear. You mean grabbing thread id (tid) or what?
2013-03-06, 04:43 PM
Id like to be able to grab the subject of new threads, and pipe it to another application, and the username of the user that posted the thread.
When someone replies I just want to be able to pull their username from the reply and nothing else. I've looked over the docs but I cant find anything besides the hooks
When someone replies I just want to be able to pull their username from the reply and nothing else. I've looked over the docs but I cant find anything besides the hooks
2013-03-06, 04:50 PM
You might have to mess with datahandler hooks, that might be a bit nasty one. Never tried to grab details right after posting a new reply or thread,.
edit: Try to use datahandler hooks and parse $post as reference in your function and for grabbing thread id, use something like:
And then you can use get_thread function I think to get thread name and other details from tid.
Not sure, try it.
edit: Try to use datahandler hooks and parse $post as reference in your function and for grabbing thread id, use something like:
$post->post_insert_data['tid']
And then you can use get_thread function I think to get thread name and other details from tid.
Not sure, try it.
2013-03-07, 12:47 AM
What do you want to do with such information? I mean, you get the thread/user and then what?
2013-03-07, 12:08 PM
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook('member_activate_emailupdated', 'account_activated_hook');
$plugins->add_hook('member_activate_accountactivated', 'account_activated_hook');
$plugins->add_hook('newthread_do_newthread_end', 'newthread_hook');
$plugins->add_hook('newreply_do_newreply_end', 'newreply_hook');
function account_activated_hook()
{
global $db, $user;
$query = $db->simple_select("userfields", "*", "ufid=".intval($user['uid']));
$userfields = $query->fetch_array();
$field4 = $userfields['fid4'];
//code to send $field4
}
The code above works fine, I get user field 4 for all users, and pass it to my other system.
function newreply_hook()
{
global $db, $user;
$query = $db->simple_select("userfields", "*", "ufid=".intval($user['uid']));
$userfields = $query->fetch_array();
$field4 = $userfields['fid4'];
//send $field4
}
function newthread_hook()
{
global $db, $mybb, $fid, $thread, $user;
$query = $db->simple_select("userfields", "*", "ufid=".intval($user['uid']));
$userfields = $query->fetch_array();
$field4 = $userfields['fid4'];
$thisuser = $mybb->user['username'];
//code to send $thisuser and $field4
}
The newthread_Hook function I can pass the username fine, but $field4 returns blank and in the newreply_hook function $field4 also returns blank. I can get $field4 properly in the account activated hook but nowhere else.
I'm not worried about parsing the thread subjects anymore, just the information in custom profile field 4. I pipe field4 to an external program that runs some commands based on the information.
Thanks for the help so far.
2013-03-08, 12:01 AM
First off you need to replace:
With:
Also you need to make $field4 a global:
$query->fetch_array();
With:
$query->fetch_array($query);
Also you need to make $field4 a global:
global $field4;
2013-03-13, 02:35 PM
(2013-03-08, 12:01 AM)Omar G. Wrote: [ -> ]First off you need to replace:
$query->fetch_array();
With:
$query->fetch_array($query);
Also you need to make $field4 a global:
global $field4;
I made the changes, get the same result as before.
2013-03-13, 09:43 PM
Does $field4 is other but null inside the function?
2013-03-14, 12:35 PM
Its not giving me anything at all for $field4. The same code works flawlessly when the user activates the account though. Maybe the profile fields cant be accessed from the reply and new thread hooks?
Pages: 1 2