Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
denote which topics I've posted in?
Avatar
mike olson
Member
sp_UserOfflineSmall Offline
Mar 8, 2017 - 2:58 pm

Is there a way when looking at the topics listed in a forum to indicate which topic the browsing user has previously posted in? I know the "New" icon will show if there was any new posts in something that they have posted in but wondering if absent any new posts in the thread if there is a way to show which ones they are involved in. 

 

I am using reboot theme if that matters. 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 8, 2017 - 3:23 pm

I guess on the whole we think that a user would know of they had posted in a particular topic or not 🙂 so currently the answer is no. I am planning on extending the notification system - hopefully some time this year - which would include this but not there yet,

My advice would be our subscriptions plugin. This will send them an email on a new post in a topic they subscribe to plus will give them a visual clue in the forum header of new posts in subscribed topics.

andy-signature.png
YELLOW
SWORDFISH
Avatar
mike olson
Member
sp_UserOfflineSmall Offline
Mar 22, 2017 - 5:32 pm

I am sure this is the absolute worst way of going about this but I figured a way to do this for my users. we have a pretty active forum during the football season and so it helps to have something to show which threads you have replied in. 

anyway I modified just before the start of column 2 in spForumViewDesktop.php and displayed two images one for if the user posted in the thread ond one for if they didn't. 

global $wpdb;

$current_user = wp_get_current_user();

if ($current_user->ID != 0) {

$myThisTopic = $spThisTopic->topic_id;
$thisUserId = $current_user->ID ;

$wpdb->get_results("select post_id from wp_sfposts where topic_id = ".$myThisTopic." and user_id = ".$thisUserId." limit 1");
$rowcount = $wpdb->num_rows;
if($rowcount != 0){
echo "[Image Can Not Be Found]";
}else{
echo "[Image Can Not Be Found]";
}

}else{
echo "[Image Can Not Be Found]";
}

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 22, 2017 - 11:06 pm

Users dont know which topics they posted in?  unless is quite old, seems odd, but hey - not judging! 😉

not exactly sure what you are trying to do with this code...  Adding another query like that would be a significant performance hit...  and not sure what you are doing with that query... you getting a list of post ids, but you really want to know if there is any poster ids that match the current user...  so if you insisted on the query, do a get_var() and just return the first post id where the poster was the user...  then you can just see if you have a value for the post id and get rid of the num_rows() too...

perhaps I would suggest that you take a look at our inspector...  forum - toolbox - data inspector...  with it you can see much of the large amounts of data already available to you on any given page...

for example, dont do the expensive wp_get_current_user() as you dont neeed all that info...  simply use the global variable $spThisUser...  the ID would be $spThisUser->ID...  and just for grins, wp has a global variable as well called $current_user so you dont need to fill it...

but actually, having read through this a couple more times, you actually want to know this on forum view..  and know if current user posted in the listed topics...  was originally thinking topic view..

Like Andy says, when we implement the notification system edge case desirements like this should be more possible directly...

Avatar
mike olson
Member
sp_UserOfflineSmall Offline
Mar 26, 2017 - 11:20 pm

This is a common feature on almost every forum I've managed whether that is ip.board (native) vbulletin or simplemachines (plugin). 

When you have users that are active in many posts and your forum is quite active it is nice to know which posts you have posted in with a visual hint. It makes scanning the list of topics easy to know which topics you have a level of interest in already. It is one of the highest features that people were missing when we converted. 

 

Query is pretty simple. I am not getting a list of post_id's. I am getting one post id.  it's returning a single post id if the user posted in that topic because of the limit 1 constraint. If they did post then an image is displayed for that topic in forum view. If not then a different topic is displayed. This is how it works in ip.board. 

 

i should have thought to put in the $spUser->ID I just had copied over the query I was using to see if I could pull whether or not a user had posted in a thread. Will switch to $spUser->ID.

 

Sans query I don't know how else I would figure out if the current viewing user had posted in the thread. I looked through the data inspector and didn't see any sort of array containing a list of users that had replied to the topic. At lease not in forum view.

I am curious to see your notifications upgrade as there are several things that are severely lacking in display on the forum itself. Whether or not someone quoted you, whether or not someone thanked/liked your post, admin notifications that a post was reported. We had to rewrite a custom section for this as well. 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 26, 2017 - 11:31 pm

I tend to remember where I post 😉  but if I want to know about updates, I subscribe... If I just have interest and want to check back, I watch...  but different strokes for different folks...  understand your use case... and we have been talking about best way (like notifications) to do it...

if you are returning a single variable, better to use get_var() than return an array, but minor impact...  just like using the api to do the work... sorry, wasnt trying to imply yours wouldnt work...

the data inspector comment was just a general comment to help you see the significant amount of data that is available on each page load...  as I said after reading through a few more times, wouldnt help in this case...

to be clear, its $spThisUser->ID...

glad to see you exploring the extreme customization of simple press...  we think its a power api that can customize to just about anything you want...  thanks for sharing...

Avatar
mike olson
Member
sp_UserOfflineSmall Offline
Mar 26, 2017 - 11:43 pm

Oh I actually love the ability to play with customization and child themes and not worrying too much about breaking anything too badly. It is pretty awesome. 

 

on the get_var() though on the wordpress site  It says:

Executes a SQL query and returns the value from the SQL result. If the SQL result contains more than one column and/or more than one row, this function returns the value in the column and row specified. If $query is null, this function returns the value in the specified column and row from the previous SQL result.

I wonder about the bolded part causing an issue. Say on one topic listing the user did respond. but in the next they didn't. Would the query then show that they did since it would default to the previous query's result? I have to be reading that wrong. 

Avatar
mike olson
Member
sp_UserOfflineSmall Offline
Mar 27, 2017 - 12:32 am

nope it isn't an issue

Avatar
mike olson
Member
sp_UserOfflineSmall Offline
Mar 27, 2017 - 12:40 am

Here is what the current working code looks like:

global $wpdb;

if ($spThisUser->ID != 0) {
$reply_count = $wpdb->get_var("SELECT COUNT(*) from wp_sfposts where topic_id = ".$spThisTopic->topic_id." and user_id = ".$spThisUser->ID." LIMIT 1");
if($reply_count != 0){
echo "<img src='http://www.vikefans.com/wp-content/sp-resources/forum-themes/reboot-child/images/iPosted.png'>";
}else{
echo "<img src='http://www.vikefans.com/wp-content/sp-resources/forum-themes/reboot-child/images/noPost.png'>";
}

}else{
echo "<img src='http://www.vikefans.com/wp-content/sp-resources/forum-themes/reboot-child/images/noPost.png'>";
}

Avatar
mike olson
Member
sp_UserOfflineSmall Offline
Mar 27, 2017 - 12:41 am

Any way I can relative link to the images? I tried thinking that ../../images would put me in the right location but it isn't right. 

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 616
Members: 17348
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10118
Posts: 79603