Now I guess if Each User has already one topic in his wp__bbp_favorites the topic stays favorited and counted but No counts is allowed for another topic again.
So the if (in_array ($topic , $topic_list)) $count++ is being a Jealous line i.e: It Only counts a user’s favorite if the user favorites only the currents topics else it doesn’t. because there exists more than one topic inside the $topic_list = array(get_usermeta ($user->id, 'wp__bbp_favorites', false)) ;
What do I do?
My Code was to test it for how many User has favourited a particular topic (Like, check how many likes a post has)…

But I guess like you said, If I understand you very well, I am testing in a scenario where User has only one topic listed in the wp__bbp_favorites meta area…
I think that fact has returned to haunt me now Robin… The picture above shows that the Currently logged in User (Who is a keymaster) has favorited the current topic but, his Favorite doesn’t count, the displayed 1 is for that of the second user who also favorites the same topic and happens to be the only topic he has favorited.
Look at the shot below then:

Now I have added more topics to the user’s wp__bbp_favorites by favouriting more topics but Its not displaying the favourites in those topics.
Another scenario on a different topic here:

Not displaying the number of favorite for the topic.
I added a new user and it was able to successfully favourite and increase the count on one of those topics that didn’t get from the previous two users.
So I think the favorite count only work if a certain user has only one topic inside their wp__bbp_favorites
Here’s the favourite count code again as I have used:
$topic = bbp_get_topic_id();
$users = get_users() ;
$count = 0;
foreach ($users as $user) {
$topic_list = array(get_usermeta ($user->id, 'wp__bbp_favorites', false)) ;
if (in_array ($topic , $topic_list)) $count++ ;
}
echo $count;
What do you suggest I do now Robin? Should I try explode explosion???
great – you may want to check the favorites for if a user has more than one favorite topic – I am suspecting your code was only tested with 1 favorite – if so same principal, if not I don’t know why one works and then other doesn’t !!
bbp_topic_post_date() & bbp_reply_post_date() returns date in this format September 2, 2018 at 4:34 am.
How does one change it to the other formats:
time ago, September 2, 2018 or 2-10-2019
And possibly other formats as preferred.
That was a hit, Robin!
<?php
$topic = bbp_get_topic_id();
$users = get_users() ;
$countsub = 0;
foreach ($users as $user) {
$topicsub_listarray = get_usermeta ($user->id, 'wp__bbp_subscriptions', true) ;
$topicsub_list = explode (',' , $topicsub_listarray) ;
if (in_array ($topic , $topicsub_list)) $countsub++ ;
}
echo $countsub;
?>
That worked it….. Thank you.
syntax error
line
add_filter('bbp_before_has_topics_parse_args', 'my_custom_display_topic_index_query ' );
should read
add_filter('bbp_before_has_topics_parse_args', 'my_custom_display_topic_index_query' );
is essence you have a space after the word query before the ‘ in 'my_custom_display_topic_index_query '
looks like it hasn’t converted to an array basically it should read
array (size = 2)
0 => 149
1 => 65
etc.
ok so let’s try replacing
$topicsub_list = array(get_usermeta ($user->id, 'wp__bbp_subscriptions', false)) ;
with
$topicsub_lista = get_usermeta ($user->id, 'wp__bbp_subscriptions', true) ;
$topicsub_list = explode (',' , $topicsub_lista) ;
Ok, so I’ve got this result, Robin!
Topic : 65
user_id: 1
array (size=1)
0 => string '149,65' (length=6)
Topic : 65
user_id: 2
array (size=1)
0 => string '145,146,65' (length=10)
0
I believe that should mean that User 1 and User 2 and currently subscribed to the topic But I still get a 0. The Replica of the Favorite should actually work but I don’t know..
hmm, can’t see why it shoudln’t work
try for test purposes
<?php
$topic = bbp_get_topic_id();
$users = get_users() ;
$countsub = 0;
foreach ($users as $user) {
$topicsub_list = array(get_usermeta ($user->id, 'wp__bbp_subscriptions', false)) ;
echo '<br>Topic : '.$topic ;
echo '<br>user_id: '.$user->id.'<br>' ;
var_dump ($topicsub_list) ;
if (in_array ($topic , $topicsub_list)) $countsub++ ;
}
echo $countsub;
?>
that should help you find out where the problem is
If I attach a redirect_to parameter to the wp-login.php it will redirect to the topic.
But if I use my custom logon page that uses the defined shortcode it will not redirect. It seems the query parameters are stripped.
Please advise.
<?php
$topic = bbp_get_topic_id();
$users = get_users() ;
$countsub = 0;
foreach ($users as $user) {
$topicsub_list = array(get_usermeta ($user->id, 'wp__bbp_subscriptions', false)) ;
if (in_array ($topic , $topicsub_list)) $countsub++ ;
}
echo $countsub;
?>
It didn’t work that way, Robin!
I got a 0 in the result, even as i was sure there’s a subscription
I’ve set up some FAQs as topics in a closed forum and would like to re-order them. I came across this code:
//* Change sort order of Topics within a specified bbpress forum
function my_custom_display_topic_index_query ($args) {
$thisforumid = bbp_get_forum_id();
if($thisforumid == 43135) {
$args['orderby'] = 'date';
$args['order'] = 'ASC';
}
return $args;
}
add_filter('bbp_before_has_topics_parse_args', 'my_custom_display_topic_index_query ' );
… but when I added it to my functions.php file it hid all the topics (even though at forum archive level it displayed the correct number of topics in the topic count column). Removing it returned my topics.
Any pointers?
I have something funny going on.
I have this code running as a snippet:
// Redirect Registration Page
function my_registration_page_redirect()
{
global $pagenow;
// Standard Registration Redirect
if ( (strtolower($pagenow) == 'wp-login.php') && (strtolower($_GET['action']) == 'register') ) {
wp_redirect( home_url('/register/') );
}
// Redirection after successful registration
if ( (strtolower($pagenow) == 'wp-login.php') && (strtolower($_GET['checkemail']) == 'registered') ) {
wp_redirect( home_url('/registration-complete/') );
}
}
add_filter( 'init', 'my_registration_page_redirect' );
Now, I start a browser and go to my website:
About Theocratic Software
I scroll to the bottom and I see my existing username and password in the login box (but not logged in).
I hit the Register button and it goes to my registration form.
I fill it in and tick the recaptcha and hit the register button.
There is a momentary delay and it just moves to the stbndard wp-login.php page with the existing username and password prefilled. I get no emails to the new account i filled in the form.
So, I hit back in my browser and my new account is filled in the form. I tick the recaptcha again and hit register again. This tie, after a delay, it takes me to my registration complete page and I do indeed get the email re: password and account activation.
I thought I had understood the registry redirection correctly so why do I get the initial issue? It has happened twice for me now.
Add this php code snippet into themes functions.php file but did not happen any changes
$topic = bbp_get_topic_id();
$users = get_users() ;
$count = 0;
foreach ($users as $user) {
$topic_list = array(get_usermeta ($user->id, 'wp__bbp_favorites', false)) ;
if (in_array ($topic , $topic_list)) $count++ ;
}
echo $count;
And this one worked Robin! Thank you!
I guess I will be patient for you to test this Robin
$topic = bbp_get_topic_id();
$users = get_users() ;
$count = 0;
foreach ($users as $user) {
$topic_list = get_usermeta ($user->id, 'wp__bbp_favorites', false) ;
if (in_array ($topic , $topic_list)) $count++ ;
}
echo $count;
I am getting the error
Warning: in_array() expects parameter 2 to be array, string given in C:\wamp\www\omna\wp-content\themes\omna2\bbpress\content-single-topic-lead.php on line 134
under 2.5.14 favorites are stored in usermeta under ‘wp__bbp_favorites’ as a list of topics
so to get a count for a topic, you would need to loop through all users and for each one count if the current topic was in it.
so something like (not tested as am tied up elsewhere, so just spending 5 mins on this)
$topic = some function to get current topic number if not already there
$users = get_users() ;
$count = 0 ;
foreach ($users as $user) {
$topic_list = get_usermeta ($user->id, 'wp__bbp_favorites', false) ;
if (in_array ($topic , $topic_list) $count++ ;
}
echo $count ;
I am trying to make up my own topic description/summary area, so I would like to display the current number of favourites and subscriptions the current topic has.
I have done successfully some other part of the area
<?php !bbp_show_lead_topic() ? bbp_topic_reply_count() : bbp_topic_post_count(); // Display No. of replies in current topic ?>
<?php bbp_topic_voice_count(); //Display No of Users in current topic ?>
<?php bbp_author_link( array( 'post_id' => bbp_get_topic_last_active_id(), 'type' => 'avatar', 'size' => 20 ) ); //Display Last Reply User ?>
<?php bbp_topic_freshness_link(); //Display Last Reply Time ?>
So I currently want a function that will display the number of favourites(priority) and subscriptions(not much priority).
Thanking you in anticipation of any working response.
This does not remove photos from the page code but from the view and that’s something. Thank you for your help!
the [bsp-display-topic-index] shortcode in my style pack plugin may be what you need
bbp style pack
once activated go to
dashboard>settings>bbp style pack>shortcodes to see how it works
Hi Robin. Thank you for responding.
database size should be no problem
I’m glad to hear that, thank you.
This is a custom convert that is a work in progress.
Forums, Topic, Replies all look good, along with a single word search, but we just noticed this issue with searching more than one word.
Another clue, after enabling debug output, “sometimes” a two word search will give this error:
“Fatal error: Allowed memory size of bytes exhausted in /opt/bitnami/apps/wordpress/htdocs/wp-includes/post.php on line 2272”
I want to use the [bbp-topic-index] shortcode, however I really want to filter by A) Public Forums, and/or B) certain forums.
When you use the topic-index shortcode, it spits out topics regardless of the forum. The problem with this is that I use BuddyPress and there are groups with private forms. I don’t want the topic-index shortcode to display these private forums.
Now, I could use the [bbp-single-forum id=$forum_id] shortcode. The problem with this, however, is that it will display ALL of the topics for that forum. Now, I COULD hide everything after the first 15 or so topics with CSS, but this is a pretty terrible solution because 1) a boatload of topics are still going to (unnecessarily) be part of the HTML markup and widespread use of display:none is bad for SEO.
Any ideas?
sorry, but we all have to live, and I don’t plan to replicate Vinny’s code for free.
Users are of course free to subscribe themselves to forums, and then they receive what you are after
try
#bbpress-forums p.bbp-topic-meta img.avatar{
display : none ;
}
Hello, will this also not remove images from the view of a specific entry in the conversation tree?
It will still load in the page code, you could delete the image by adding files. I tried but the site is broken because I do not know how to edit the line of code that displays it loop topic so as not to spoil and delete only the avatar on the topic list page