Info
- 5 posts
- 3 voices
- Started 2 years ago by clarklab
- Latest reply from iftomkins
- This topic is not resolved
conditionals with is_forum()
-
- Posted 2 years ago #
Is there a way to add a parameter to the function to check if the user is viewing a specific forum (by forum name or ID). It seems like it would be included I just can't find a full explanation of the function and figured someone here might know.
-
- Posted 2 years ago #
To learn how bbPress works, I would suggest browsing the source of the top level files in the bbPress root.
is_forumsimply checks the url and does not know which forum it is in
but it can be used before repermalink happens (similar to wordpress)to get the current forum, in theory you should be able to
global $forum_id;And then the
$forum_idis the current forum number. You can then use the api to get the forum name, etc. if desired.This may not work in all cases as bbPress has some nasty code in some places that even in 1.0 still does not reset the counter after loops. For example a forum page that has some sub-forums, the
$forum_idmight very well be the last sub-forum displayed (if the bug has not been fixed yet).You also cannot fetch
$forum_idbefore repermalink happens which is afterbb_initis triggered. Shouldn't be a problem unless you are trying to execute code while a plugin is loading vs. after initps.
is_forumis deprecated in 1.0, usebb_is_forum -
- Posted 2 years ago #
I tried inserting
<?php global $forum_id; echo $forum_id; ?>just to test if I could grab the value and I could not. I tried it in a few places with no luck. What am I doing wrong?
Also thanks for all the plugins. I've got like a dozen of them running on my install.
-
- Posted 2 years ago #
d'oh! this works:
<?php global $topic; echo "$topic->forum_id"; ?>should've mentioned I was on a topic page
-
- Posted 1 year ago #
thanks guys, just what I needed. I'm creating RSS-driven email lists through mailchimp, so those unfamiliar with RSS can subscribe easily to each forum topic they choose.
Then using CK's code to get the forum ID, showing the proper email signup form for each forum page that corresponds with that forums' RSS-driven campaign on mailchimp.
<?php global $topic; $current_topic = $topic->forum_id; echo $current_topic; if ($current_topic==2) { include('mailchimp/getting-started.php'); } ?>Maybe someone else will find useful? It's a bit labor intensive to set up, but I couldn't figure out a better way to let people subscribe to individual forums.
-
You must log in to post.