Detailed List Showing Number of Topics etc by each Member
-
I can already define a Role and allocate members to that Role.
Wouldn’t it be be great if I could show a list at the front end of all the members in a particular role, together with the number of Topics and the number of Replies each member has created. The list would be sorted on either Name or Number of Topics created.
For Example
Role [User Activity]
Name Grade Topics Replies
Julie Jones ** 178 278
John Smith * 34 56
Tony Robins 5 2
Barry Evans 0 0I truly believe that this would encourage greater use of the Forum as it would encourage competition whilst naming and shaming those that don’t submit to the Forum. Also each member could be allocated a performance rating dependent on the number of Topics they have created. The actual break points for the Topics and the Names for the Grades can be administrator definable. I’ve just used a star rating for my example.
Topics Grade
0 – 10
10 – 100 *
100 – 200 **
200 – 300 ***
etc
-
Sorry, I forgot about the editing.
Role [User Activity]
Name………..Grade…Topics…Replies
Julie.Jones….**……178……278
John.Smith…..*…….34…….56
Tony.Robins…………5……..2
Barry.Evans…………0……..0Topics…….Grade
0-10
10-100…….*
100-200……**
200-300……***Hi @supernova42,
Try to make from this https://www.asgaros.de/support/?view=thread&id=137-
This reply was modified 7 years, 6 months ago by
Yworld.
Hi Yworld
I have added the code from your thread but it doesn’t seem to do anything. Do I need to activate something or modify something etc.
Cheers
shortcode for output [forum_profile]
Yes that works. It shows the Topics and Messages created by myself.
e.g
Created topics: 226
Messages created: 336So each user would be able to see how many how many Topics and Messages they have created.
I just need someone to apply this so that I can show a list of ALL members with their Topics and Messages created – which would be visible by all logged in users.
Thanks
I have added the short-code to a text widget and it shows up on the right hand side of my page complete with the logged in members photo together with the Number of Topics Created and the Number of Messages Created.
Unfortunately, if the Logged in user has not created any topics or messages then no text is shown – only the photo is shown.
How can I modify the code to show the following if appropriate
Topics Created: 0
Messages Created: 0Thanks
@supernova42 replace this code:
function AsgarosForumProfileShortcodes($user_ID){ global $user_ID; if(is_user_logged_in()) { $content .= '<div>'.get_avatar($user_ID, 100).'</div>'; $groupsOfUser = AsgarosForumUserGroups::getUserGroupsForUser($author_id); if (($groupsOfUser[0]->name) !== NULL) { $content .= '<div class="">'.($groupsOfUser[0]->name).'</div>'; } $content .= AsgarosForumProfile($user_ID, $type='asf_issues', $title='Created topics: '); $content .= AsgarosForumProfile($user_ID, $type='asf_reply', $title='Messages created: '); } else { $content .= '<div>'.get_avatar($user_ID, 100).'</div>'; $content .= 'Created topics: 0 '; $content .= 'Messages created: 0'; } return $content; } add_shortcode( 'forum_profile', 'AsgarosForumProfileShortcodes' );
I have not tested ??
-
This reply was modified 7 years, 6 months ago by
Yworld.
Hello @supernova42
I think this is also a feature which I could introduce with the planned profile-functionality so the links could directly link to the corresponding profile-page.
The original function given by YWorld works, however it shows a blank when there are 0 Topics and Messages. I want to actually show that 0 and YWorld provided a slightly modified file which unfortunately does not work. It doesn’t seem to be reaching that else statement. Can you advise what is wrong with the modified file.
Thanks
***************************************
UPDATE
***************************************
The original function that YWorld provided works well. It gives the Number of Topics and Number of Messages together with the Avartar of the logged in user.e.g.
Topics Created: 78
Messages Created: 89This is great.
However, when the logged in user has not created any Topics or Messages instead of giving
Topics Created: 0
Messages Created: 0It leaves out these lines and nothing is displayed. I want to display the fact that the user has left 0 Topics and 0 Messages.
The modified function that YWorld left simply displays the following when the user is NOT logged in.
Topics Created: 0
Messages Created: 0How do I modify the code please
Many Thanks
@supernova42 Check the code:
<?php if (!defined('ABSPATH')) exit; // статистика asgaros forum function AsgarosForumProfile($user_id, $type, $title){ if (!class_exists('AsgarosForumStatistics')) return false; // If asgaros is not enabled global $wpdb, $otfm_asf_cnt, $cnt; if(!$otfm_asf_cnt){ // Once filling the global variable - subsequent options for requesting functions are not sent to the database $otfm_asf_cnt = $wpdb->get_results("" . "SELECT " . "COUNT(parent_id) as total_posts, " . "count(DISTINCT parent_id) AS forum_start " . "FROM ".$wpdb->prefix."forum_posts " . "WHERE author_id = ".$user_id." " . "GROUP BY author_id " . "",ARRAY_A); if(!$otfm_asf_cnt) $otfm_asf_cnt[0] = array('none'); // if the query did not return anything - write 'none' to subsequent requests in the idle not to drive } if($type == 'asf_issues'){ // created themes $cnt = $otfm_asf_cnt[0]['forum_start']; } if($type == 'asf_reply'){ // the total number of messages $cnt = $otfm_asf_cnt[0]['total_posts']; } if(!$cnt) return false; $out = '<div class="otfm_asgrs_blk otfm_asgrs_'.$type.'">'; $out .= '<span class="otfm_asgrs_title">'.$title.'</span>'; $out .= '<span class="otfm_asgrs_cnt">'.$cnt.'</span>'; $out .= '</div>'; return $out; } function AsgarosForumProfileShortcodes($user_ID){ global $user_ID, $cnt; if(!is_user_logged_in()) return false; $content .= '<div>'.get_avatar($user_ID, 100).'</div>'; $groupsOfUser = AsgarosForumUserGroups::getUserGroupsForUser($author_id); if (($groupsOfUser[0]->name) !== NULL) { $content .= '<div class="">'.($groupsOfUser[0]->name).'</div>'; } if ($cnt == 0){ $content .= '<span class="otfm_asgrs_title">Created topics: 0</span>'; $content .= '<span class="otfm_asgrs_title">Messages created: 0</span>'; } else if ($cnt > 0) { $content .= AsgarosForumProfile($user_ID, $type='asf_issues', $title='Created topics: '); $content .= AsgarosForumProfile($user_ID, $type='asf_reply', $title='Messages created: '); } return $content; } add_shortcode( 'forum_profile', 'AsgarosForumProfileShortcodes' );
styles add ??
Hi YWorld
This is a great routine which mosts people should add to their forum.
I’ve installed the new code but now it gives a ‘0’ regardless of how many topics or messages have been posted by the user. It’s reading $cnt as 0 all the time.
It was giving the correct number of Topics and Messages on the previous coded function but didn’t show when it was 0
Cheers
@supernova42 Check the code ?? :
function AsgarosForumProfile($user_id, $type, $title){ if (!class_exists('AsgarosForumStatistics')) return false; // If asgaros is not enabled global $wpdb, $otfm_asf_cnt, $cnt; if(!$otfm_asf_cnt){ // Once filling the global variable - subsequent options for requesting functions are not sent to the database $otfm_asf_cnt = $wpdb->get_results("" . "SELECT " . "COUNT(parent_id) as total_posts, " . "count(DISTINCT parent_id) AS forum_start " . "FROM ".$wpdb->prefix."forum_posts " . "WHERE author_id = ".$user_id." " . "GROUP BY author_id " . "",ARRAY_A); if(!$otfm_asf_cnt) $otfm_asf_cnt[0] = array('none'); // if the query did not return anything - write 'none' to subsequent requests in the idle not to drive } if($type == 'asf_issues'){ // created themes $cnt = $otfm_asf_cnt[0]['forum_start']; } if($type == 'asf_reply'){ // the total number of messages $cnt = $otfm_asf_cnt[0]['total_posts']; } if(!$cnt) return false; $out = '<div class="otfm_asgrs_blk otfm_asgrs_'.$type.'">'; $out .= '<span class="otfm_asgrs_title">'.$title.'</span>'; $out .= '<span class="otfm_asgrs_cnt">'.$cnt.'</span>'; $out .= '</div>'; return $out; } function AsgarosForumProfileShortcodes($user_ID){ global $user_ID, $cnt; if(!is_user_logged_in()) return false; $author_posts = AsgarosForumProfile($user_ID, $type='asf_reply', $title=''); $content .= '<div>'.get_avatar($user_ID, 100).'</div>'; $groupsOfUser = AsgarosForumUserGroups::getUserGroupsForUser($author_id); if (($groupsOfUser[0]->name) !== NULL) { $content .= '<div class="">'.($groupsOfUser[0]->name).'</div>'; } if ($cnt == 0){ $content .= '<span class="otfm_asgrs_title">Created topics: 0</span>'; $content .= '<span class="otfm_asgrs_title">Messages created: 0</span>'; } else if ($cnt > 0) { $content .= AsgarosForumProfile($user_ID, $type='asf_issues', $title='Created topics: '); $content .= AsgarosForumProfile($user_ID, $type='asf_reply', $title='Messages created: '); } return $content; } add_shortcode( 'forum_profile', 'AsgarosForumProfileShortcodes' );
@supernova42 Check
Group, topics, Messages:function AsgarosForumProfile($user_id, $type, $title){ if (!class_exists('AsgarosForumStatistics')) return false; // If asgaros is not enabled global $wpdb, $otfm_asf_cnt, $cnt; if(!$otfm_asf_cnt){ // Once filling the global variable - subsequent options for requesting functions are not sent to the database $otfm_asf_cnt = $wpdb->get_results("" . "SELECT " . "COUNT(parent_id) as total_posts, " . "count(DISTINCT parent_id) AS forum_start " . "FROM ".$wpdb->prefix."forum_posts " . "WHERE author_id = ".$user_id." " . "GROUP BY author_id " . "",ARRAY_A); if(!$otfm_asf_cnt) $otfm_asf_cnt[0] = array('none'); // if the query did not return anything - write 'none' to subsequent requests in the idle not to drive } if($type == 'asf_issues'){ // created themes $cnt = $otfm_asf_cnt[0]['forum_start']; } if($type == 'asf_reply'){ // the total number of messages $cnt = $otfm_asf_cnt[0]['total_posts']; } if(!$cnt) return false; $out = '<div class="otfm_asgrs_blk otfm_asgrs_'.$type.'">'; $out .= '<span class="otfm_asgrs_title">'.$title.'</span>'; $out .= '<span class="otfm_asgrs_cnt">'.$cnt.'</span>'; $out .= '</div>'; return $out; } function AsgarosForumProfileShortcodes($user_ID){ global $user_ID, $cnt; if(!is_user_logged_in()) return false; $author_posts = AsgarosForumProfile($user_ID, $type='asf_reply', $title=''); $content .= '<div>'.get_avatar($user_ID, 100).'</div>'; $groupsOfUser = AsgarosForumUserGroups::getUserGroupsForUser($user_ID); if (($groupsOfUser[0]->name) !== NULL) { $content .= '<div class="">'.($groupsOfUser[0]->name).'</div>'; } if ($cnt == 0){ $content .= '<span class="otfm_asgrs_title">Created topics: 0</span>'; $content .= '<span class="otfm_asgrs_title">Messages created: 0</span>'; } else if ($cnt > 0) { $content .= AsgarosForumProfile($user_ID, $type='asf_issues', $title='Created topics: '); $content .= AsgarosForumProfile($user_ID, $type='asf_reply', $title='Messages created: '); } return $content; } add_shortcode( 'forum_profile', 'AsgarosForumProfileShortcodes' );
Success YWorld
I would definitely recommend this function.
Just one little thing
When the User has more than 0 messages it displays
Topics Created: 45
Messages Created: 67However when the user has zero topics etc it displays
Topics Created: 0 Messages Created: 0all on the same line.
How do I force a line break in phpThanks again
-
This reply was modified 7 years, 6 months ago by
- The topic ‘Detailed List Showing Number of Topics etc by each Member’ is closed to new replies.