PDA

View Full Version : HOW-TO Check if user is subscribed to thread?


addamroy
08-01-2013, 12:00 PM
I'm looking for some kind of conditional in SHOWTHREAD to check if a user is subscribed to the thread.

Basically as of now I have a 'subscribe to thread' button that shows only to members. I was hoping there is a way to add one more conditional to check if the user already subscribed to the thread, in which case the button would disappear.

mokujin
08-01-2013, 12:39 PM
Try this: add new plugin showthread_query
$hook_query_fields .= " ,subscribethread.*";

$hook_query_joins .= " LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON (subscribethread.threadid=post.threadid AND subscribethread.userid=post.userid)";

Then in postbit (or postbit_legacy) add this to everywhere.

<vb:if condition="$post['subscribethreadid']">Subscribed</vb:if>

Xexiu
03-17-2014, 09:44 PM
And how to make it work on vbulletin 3.8? Thanks

blind-eddie
03-17-2014, 10:59 PM
Create the plugin as stated above, name it Subscribed.
Hook Location, select, showthread_query

In the Plugin PHP Code message area,
Add:
$hook_query_fields .= " ,subscribethread.*";

$hook_query_joins .= " LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON (subscribethread.threadid=post.threadid AND subscribethread.userid=post.userid)";


In your postbit or postbit_legacy template find:


<if condition="$post['signature']">
<!-- sig -->
<div>
__________________<br />
$post[signature]
</div>
<!-- / sig -->
</if>
<br><br><br><br><br><br><br><br><br>

Add below:

<div align="left">
<if condition="$post['subscribethreadid']">Subscribed</if>
</div>

Barcham
03-17-2014, 11:15 PM
Just install this mod...[OzzModz] Users Subscribed To Thread Block. I have this running and it's great.

https://vborg.vbsupport.ru/showthread.php?t=305173

blind-eddie
03-17-2014, 11:33 PM
Just install this mod...[OzzModz] Users Subscribed To Thread Block. I have this running and it's great.

https://vborg.vbsupport.ru/showthread.php?t=305173

The question ask on this 8 month old thread was:

And how to make it work on vbulletin 3.8? Thanks

I answered his 3.8 question, your link sends the member to a 4.0 addon, it will not work on vb 3.8

Xexiu
03-17-2014, 11:41 PM
Thanks blind.

To make it work under ForumDisplay also? Or make it work on all site? Should I change hook location to "global start"?

Much thanks.

blind-eddie
03-18-2014, 12:10 AM
No plugin needed...

There is an image on the Forum Display page that shows if you are subscribed.
Its a bit small, https://vborg.vbsupport.ru/images/misc/subscribed.gifbut does its job.
You would just need to change the image to your liking on the Forum Display page

Barcham
03-18-2014, 12:16 AM
The question ask on this 8 month old thread was:



I answered his 3.8 question, your link sends the member to a 4.0 addon, it will not work on vb 3.8

Agreed, I didn't realize the age of the thread and I was directing my reply to the person who started the thread, as this is the VB4 section after all. :)

Xexiu
03-18-2014, 12:21 AM
Do you mean this (?):
<if condition="$show['subscribed_to_forum']">
<a href="subscription.php?$session[sessionurl]do=removesubscription&amp;f=$foruminfo[forumid]" rel="nofollow">$vbphrase[unsubscribe_from_this_forum]</a>
<else />
<a href="subscription.php?$session[sessionurl]do=addsubscription&amp;f=$foruminfo[forumid]" rel="nofollow">$vbphrase[subscribe_to_this_forum]</a>
</if>

From forumdisplay template. But when I add the same code to the forumhome_forumbit_level1_post, doesnt work.

Any suggestions?

blind-eddie
03-18-2014, 01:02 AM
You do not need to edit anything to get it to work on Forum Display, there is an image ( https://vborg.vbsupport.ru/images/misc/subscribed.gif ) that shows if you are subscribed on the Forum Display pages .... but that's just for you, not all members.

--------------- Added 1395104881 at 1395104881 ---------------

Agreed, I didn't realize the age of the thread and I was directing my reply to the person who started the thread, as this is the VB4 section after all. :)

I know, lol I was just messing with you.
In fact, I did not realize it was an old thread until your post, I thought I posted 3.8 info in a 4.0 forum.. again. I then re-read the thread.

Xexiu
03-18-2014, 01:28 AM
Hmmmm I cant see it. Im modifying a style but anyway, was having a look at the default style and I dont see the icon. Can you post a screenshoot please. Here is mine.

http://imageshack.com/a/img542/7016/y7gi.png

And here is what I'm trying to do:

https://imagizer.imageshack.us/v2/1220x457q90/853/97i4.png

blind-eddie
03-18-2014, 01:58 AM
Check your usergroup permissions and see if you are able to subscribe to threads, when you do subscribe to any thread in 3.8, you will see the https://vborg.vbsupport.ru/images/misc/subscribed.gif image to the far right of the thread name on forum display.

Your second SS shows the check mark for subscribed threads.

Xexiu
03-18-2014, 02:19 AM
Yeah, on my SS I have the check mark (manually added) on template forumhome_forumbit_level1_post, and shows the check mark. But when I click it it redirects me to subscription folder (I add the forum to the subscription list), but the check marks are still there.

After I subscribe to a forum, there is supposed to change to "X" (unsubscribe from this forum), instead it still show the valid checkmark.

Here is my forumhome_forumbit_level1_post code:

<if condition="$show['subscribed_to_forum']">
<a href="subscription.php?$session[sessionurl]do=removesubscription&amp;f=$forum[forumid]" rel="nofollow" title="Unsubscribe to $forum[title]" rel="nofollow">X</a>

<else />

<a href="subscription.php?$session[sessionurl]do=addsubscription&amp;f=$forum[forumid]" rel="nofollow" title="Subscribe to $forum[title]">✓</a></if>

blind-eddie
03-19-2014, 02:23 AM
I have found that using the code posted in post # 2 & 4 will cause the OP to become a guest.
It happened to me & threw up database errors when a member is switched to a guest if the have post/threads in some admin forums.
I removed it from my test site.