Only Apply in First Post
#1
Hi Guys, 

Im working in a plugin but I can't do this plugin only works in the first post I was thinking in use:

if $post['pid'] == 1 then

But Im not sure where put it or if I need to call another global variable this is a part of the code

global $mybb,$lang,$templates,$thread;
	
	// Will run only if it's being called from newthread.php.
	
	if((THIS_SCRIPT == "showthread.php" || THIS_SCRIPT == "newreply.php" || THIS_SCRIPT == "syndication.php") && ($mybb->settings['hide_link_enabled'] || $mybb->settings['hide_lock_enabled']) && hide_validate($thread['fid']) && !is_moderator($thread['fid']))
	
	{

Its working now but affect all the post of a thread, my idea its only limit to the first post only.-

Thanks!
Reply
#2
actually $post['pid'] => gives post ID number eg. above post has pid 1132898

And check again your logic. from where should it run and how to put it ?
if we want to run some thing only on thread page then we check if the page is showthread

for the plugins, basically we have to use the hooks
Reply
#3
$plugins->add_hook('postbit', 'foo');
function foo(&$post)
{
		global $thread, $plugins;

		if($thread['firstpost'] == $post['pid'])
		{
			// $post is the first post and uses all postbit* templates
			$post['message'] .= '<br />This is the first post!';
		}

		$plugins->remove_hook('postbit', 'foo');
}
Reply
#4
Thanks .m. and Omar G.

The code finish like this, works fantastic:

global $mybb,$lang,$templates,$thread,$post;
    
    
   if($thread['firstpost'] == $post['pid'])
    {
    if((THIS_SCRIPT == "showthread.php" || THIS_SCRIPT == "newreply.php" || THIS_SCRIPT == "syndication.php") && ($mybb->settings['hide_link_enabled'] || $mybb->settings['hide_lock_enabled']) && hide_validate($thread['fid']) && !is_moderator($thread['fid']))
    
    { etc etc

Something I want to know is, in my case use the Showthread.php file to start the function, the problem is, this hide link affect me the links of signature (links to image or links), It's some way to avoid the signature part of the thread?

Thanks.-
Reply
#5
We will need more about the code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)