MyBB Community Forums

Full Version: Two variable in single code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Please help me to put code through template condition by using if.

I want to show last post of specific forum to specific group.
How to do it?

<if in_array($mybb->user['usergroup'],array(4,9)) ; here i also want to add forum id  then>
{last post}
</if.
please help me to proper code for this
Not sure if that's the variable you're looking for, but;

<if in_array($mybb->user['usergroup'],array(4,9)) and {$forum['fid']} then>{last post}</if>
i use below code
<if (in_array($mybb->user['usergroup'], array(4,8,9)) && in_array($forum['fid'], array(168))) then>

<span class="smalltext">
<a href="{$lastpost_link}" title="{$full_lastpost_subject}"><strong>{$lastpost_subject}</strong></a>
<br />{$lastpost_date}<br />{$lang->by} {$lastpost_profilelink}</span>

<else> Protected Forum
</if>

But it show 'Protected Forum' under all forum last post rather than in forum id 168.
Is there any issue with code?
Please Help someone...
Its Look Simple but no one want to correct this code?
Please help?
Can anyone help in this matter?
i tried in many way but not working.
I will be very thankful to you guys.
That's obvious when you realize you're checking for the forum identifier existence.

if (in_array($forum['fid'], [168])) {
  // Display something if you're viewing the forum with ID 168
}

If you want to display the last post of a specific forum in every forum you must write some low level code, selecting your desired info from the database since the last post data of a specific thread is available only when you watch a specific forum. Using PHP in templates is not enough for this task, or it might be extremely inefficient.
Thanks shade.

Can you modify below code please for me.

<if (in_array($mybb->user['usergroup'], array(4,8,9)) && in_array($forum['fid'], array(168))) then>

<span class="smalltext">
<a href="{$lastpost_link}" title="{$full_lastpost_subject}"><strong>{$lastpost_subject}</strong></a>
<br />{$lastpost_date}<br />{$lang->by} {$lastpost_profilelink}</span>

<else> Protected Forum
</if>

I guess you didn't read the whole post then. You cannot accomplish what you are asking just by using PHP in templates. You must hook into MyBB's core code and select the latest post of your target thread/forum from the database.
Thanks..
I am not expert.
can you guide me please.
Pages: 1 2