MyBB Community Forums
How to hook into the Showthread and remove - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: How to hook into the Showthread and remove (/thread-183130.html)



How to hook into the Showthread and remove - expat - 2015-10-06

How to hook into the Showthread and remove the post bit?

$plugins->add_hook("showthread", "myPlugin_showthread");



if some setting is met, how can i remove the 
{$posts}


{$first_post}{$posts}


Can someone move it to the plugins?

function myPlugin_showthread(&$posts)
{}

is this correct?


RE: How to hook into the Showthread and remove - Destroy666 - 2015-10-09

No, your code doesn't make any sense.
http://docs.mybb.com/1.8/development/plugins/creating-modifying-templates/#editing-templates


RE: How to hook into the Showthread and remove - expat - 2015-10-10

What I need to do is

Check for usergroups, where only admins and moderators can see replies

If is_user(3,4,6) {posts}


So  how do pass variable to template
Nb I am on mobile


RE: How to hook into the Showthread and remove - Destroy666 - 2015-10-10

Well, you can use the is_member() function to check groups and the is_moderator() function to check whether the user is moderator on X forum or globally.
https://github.com/mybb/mybb/blob/feature/inc/functions.php#L6934
https://github.com/mybb/mybb/blob/feature/inc/functions.php#L6934


RE: How to hook into the Showthread and remove - expat - 2015-10-11

but that doesnt allow me to leanrn how to create a plugin grrrrrrr


RE: How to hook into the Showthread and remove - Destroy666 - 2015-10-11

(2015-10-11, 06:19 AM)expat Wrote: but that doesnt allow me to leanrn how to create a plugin grrrrrrr

And what can we do about that? I'm not sure what you're trying to say... Only you can control and broaden your own knowledge.

First you need to learn PHP, at least basics: https://secure.php.net/manual/
MySQL too: http://dev.mysql.com/doc/
And basics such as HTML/CSS.

Then you can start writing basic plugins: http://docs.mybb.com/
You can also check other plugins/core to learn how something works in MyBB.


RE: How to hook into the Showthread and remove - Omar G. - 2015-10-12

First of all $first_post is not a MyBB variable, it is a xThreads one, is not it?

You need to hook at showthread_start/end for whatever you are trying to do.

Check my plugin for an example.
https://github.com/Sama34/OUGC-Guests-See-Only-First-Post/blob/master/Upload/inc/plugins/oucg_gsofp.php

Although my plugin does use a dirty method I wouldn't really recommend.


RE: How to hook into the Showthread and remove - expat - 2015-10-12

(2015-10-12, 06:25 AM)Omar G. Wrote: First of all $first_post is not a MyBB variable, it is a xThreads one, is not it?

You need to hook at showthread_start/end for whatever you are trying to do.

Check my plugin for an example.
https://github.com/Sama34/OUGC-Guests-See-Only-First-Post/blob/master/Upload/inc/plugins/oucg_gsofp.php

Although my plugin does use a dirty method I wouldn't really recommend.

hey thanks, i am actually decoding your plugins just to learn how to do a plugin Toungue