Jump to content
WebFlake
  • 0

Get viewing member group id in custom bbcode


Guest funboss

Question

Guest funboss

Hi there,

 

I'm trying to make a custom bbcode but I face some parsing problems and started to follow the guide more precisely. The one problem I ran into is about showing user groups different output. The guides lack information and with the examples (i.e. default.php) I still didn't manage to make it work, although I think it has to do with the functions (__construct, _buildOutput or _replaceText).

 

Below are two examples (in different functions, so it's not the variables). I already tried to change the position (_buildOutput or _replaceText) and the operators (===1 or ==1), for the sake of (my) stupidity.

 

To sum up, I'd like to know (a) how to differentiate between user groups or (b) another solution for my problem.

 

if(IPSMember::isInGroup($this->memberData,array(1,2,8))) {  $txt = substr_replace( $txt, $this->_buildOutput( $content ), $this->cur_pos, (stripos( $txt, $close_tag, $this->cur_pos ) + strlen($close_tag) - $this->cur_pos) );} else {  $txt = substr_replace( $txt, $this->_buildOutput( "<strong>Something else</strong>" ), $this->cur_pos, (stripos( $txt, $close_tag, $this->cur_pos ) + strlen($close_tag) - $this->cur_pos) );}
if($this->memberData['member_group_id']=="1" || $this->memberData['member_group_id']=="2" || $this->memberData['member_group_id']=="8") {  $output = "<div class='bbc_df'><strong>Something else</strong></div>";} else {  $output = "<div class='bbc_df'>{$content}</div>";}

 

Thanks in advance.

 

Greetings,

funboss

 

Edit: In the code above the if-statement always returns false. I returned the member variable and it seems to show the group id of the poster.

Edited by funboss
Link to comment
Share on other sites

Recommended Posts

  • 0

No every time a post is viewed it is put in cache as it was read the first time. So if you were the first to read a post that has the new bbcode than it will have your  group id. UNTIL you clear the cache again. Turn cacheing off and then clear the and see how it works.

 

Last reply from me...

Link to comment
Share on other sites

  • 0
Guest funboss

Yes, that's right. I read my message once again and it's quite confusing for a simple question like mine.

 

I'm looking for the variable which returns the group ID of the logged in member, thus the member who is viewing the topic.

 

Edit: It could be the same, but then I need to know how to pass that variable through the functions required to make custom bbcode.

Edited by funboss
Link to comment
Share on other sites

  • 0
Guest funboss

Thanks for your response, but I already tried this. It makes no difference in what manner you write the statement if you use the same variable (which returns the member group id of the member posting the bbcode).

 

As said before, I think it has to do with setting the variable and passing it through the function(s).

 

I cannot imagine it's difficult. I used the variable which we use here to echo the member viewing the forum in the template. But unfortunately in the guide this variable is set to the member who posted the bbcode.

Edited by funboss
Link to comment
Share on other sites

  • 0
Guest funboss

One line above the if-statement the variable is defined as the content between the tags. ;)

 

The function works all right. I only need (to pass) the proper variable to differentiate between user groups. That's the only problem I got atm.

Edited by funboss
Link to comment
Share on other sites

  • 0

If you are creating it then why would you check right after it. But really doesn't matter.

 

Here is my test with your code ...

 

I used this as admin group 4

[vip] is my group id!![/vip]

 

got this

BBCode Test:::4 Speciaal berichtAlleen zichtbaar voor leden met een speciale status.

 

and in forums a test member got this

Posted Today, 11:59 AM ::3 Speciaal berichtAlleen zichtbaar voor leden met een speciale status.

 

Working just fine for me..

Link to comment
Share on other sites

  • 0
Guest funboss

If you are creating it then why would you check right after it. But really doesn't matter.

To check whether there is content between the tags. There is no use in parsing empty variables.

 

What did you change in de code I've sent you? The variable contains the group id of the member posting the bbcode. Everyone who views the topic sees the group id of the poster. The test member should only view the topic and not use the bbcode.

Link to comment
Share on other sites

  • 0
Guest funboss

That would be weird, right? So the member didn't use the bbcode and get its own group id and not the group id of the admin who posted the bbcode? That's where it is all about.

 

Edit: It's quite reasonable that it won't work as there are no viewers when the content is parsed. I tried the public function "preDisplayParse", because I think this function will be called everytime a member is viewing the topic. No result yet. I hope you do understand what I'm trying to do here, since it makes no sense to show the posters group id.

 

A solution would be to implement the if-statement (to differentiate between user groups) in the template somehow, but I'd rather prevent this.

Edited by funboss
Link to comment
Share on other sites

  • 0

No you misunderstand...... Or I misunderstand what you want.

 

Here is the topic with a guest viewing it . It shows the 4 for the post the admin entered and the 3 for the post the member added.

tester Newbie  Members < Guests | Administrators | Moderators   3 posts  Posted 25 June 2013 - 03:59 PM ::3 Speciaal berichtAlleen zichtbaar voor leden met een speciale status.Report #2   Lock Down Administrator Administrators < Guests   6 posts  Posted Today, 05:14 PM ::4 Speciaal berichtAlleen zichtbaar voor leden met een speciale status.
Edited by Lock Down
Link to comment
Share on other sites

  • 0
Guest funboss

Yes, you misunderstand what I want.

 

It shouldn't matter what member (group) posts the bbcode. I'd like to show different output for certain member groups based on viewers and not on posters.

 

So, if you post and view the message with an admin and a member from a different group you'll see no difference there. And that's what I try to accomplish.

Edited by funboss
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...