List all Tags?
-
Is there a way to list all the tags and, if possible, which user wrote those tags?
-
i would also like to know the answer to this
Do you mean per post or just all tags on the site? The latter would have issues as tags are reused.
I mean all the tags used on the site, so we could see two columns
Tag | User
so each tag could have multiple users who used it.
Some users are using inappropriate tags on posts. We want a public list so we can name and shame them. Currently the only way to see who posted what tag is to do an SQL query along the lines of
SELECT bb_users.user_nicename, bb_terms.slug, bb_topics.topic_slug
FROM bb_terms
INNER JOIN bb_term_taxonomy ON bb_term_taxonomy.term_id = bb_terms.term_id
INNER JOIN bb_term_relationships ON
bb_term_relationships.term_taxonomy_id =
bb_term_taxonomy.term_taxonomy_id
INNER JOIN bb_topics ON bb_term_relationships.object_id = bb_topics.topic_id
INNER JOIN bb_users ON bb_term_relationships.user_id = bb_users.ID
WHERE bb_terms.slug = 'TAG NAME'> Currently the only way to see who posted what tag is to do an SQL query
That’s not true. You can see who posted a specific tag by looking at the source of the page where a tag is displayed. In the source, you will see something like this:
<li id="tag-1785_278"
The 1785 is the tag_id and the 278 is the user_id. If you want to moderate a user who is posting inappropriate tags, you have your id right there.
I learned this recently on these forums, but I can’t find the post that explained it originally.
that’s good to know, thanks.
I just added the following to topic-tags.php (after <?php bb_tag_remove_link(); ?> )
<?php if ( bb_current_user_can( 'manage_tags', get_topic_id() )): ?><a href="/forum/profile.php?id=<?php echo $tag->user_id; ?>">user</a><?php endif; ?>
so there is a quick link to the users profile to see who posted that tag.
Not perfect but easier than running that SQL!
improved:
<?php if ( bb_current_user_can( 'manage_tags', get_topic_id() )): ?> - <a href="/forum/profile.php?id=<?php echo $tag->user_id; ?>"><?php echo get_user_name( $tag->user_id ); ?></a><?php endif; ?>
this is great, thank you.
To get the ‘who posted that tag’ functionality in 1.06 you need to edit a core file (which is frowned upon – but we really need to moderate inappropriate tags and ban if necessary).
bb-includes/function.bb-template.php
and replace line 2529 with this:
$poster = get_user_name( $tag->user_id );
return "<small> - <a href="/forum/profile.php?id=$tag->user_id">$poster</a></small> [<a href='$url' class='delete:$list_id:tag-{$tag->tag_id}_{$tag->user_id}' title='$title'>×</a>]";where /forum/ is the subfolder of your forum.
It appears to be working well – users have their name next to the tags they posted, and the ability to delete their own tag; whilst not seeing who added the other tags.
That’s a great idea. I have that problem with inappropriate tags too. I wonder if this will help.
my line 2529 was blank so i replaced the nearest thing i could see that was similar to
return "<small> - <a href="/forum/profile.php?id=$tag->user_id">$poster</a></small> [<a href='$url' class='delete:$list_id:tag-{$tag->tag_id}_{$tag->user_id}' title='$title'>×</a>]";
now, either as a result of this or as a result of the updates described in this page:
https://bbpress.org/forums/topic/theme-template-files-to-change-for-10#post-23794
…my tag area no longer automatically reloads when a tag is added, even though the tag is committed to the db and can be seen if you reload the page. i am a bit worried that users are going to be confused by this. i bet i have replaced the wrong line, but i am not sure…
actually, mine does that too. Hadn’t noticed until now.
I’m not sure why it would do that but will have a look into it.
i think it’s reloading properly for new (unique) tags, but not for tags that already exist in the database.
yes, that appears to be the problem, and most likely something to do with fetching the user id of the tag poster. As this will be, at this point, set to the last person who used that tag, and the current user cannot see who posted a tag unless it is theirs. So there will be some permissions problem going on.
let this be a lesson to you regarding editing core files!
ah. ok. i might change it back to how it was before then. thanks for the update!
i just had a brainwave;
is it possible to change the code so ALL users can see who wrote each tag.
the delete function could be removed for everyone except admins.
this would fix the above permissions problem, wouldn’t it? on our forum, tags don’t really need to be anonymous.
Probably. Looking at this page for an example…
<div id="othertags">
Tags:
<ul id="yourtaglist">
<li id="tag-87_349081"><a href="https://bbpress.org/forums/tags/tag" rel="tag">tag</a> </li>
</ul>
</div>349081 is the user ID of whomever made the tag
tag-87 is the tag ID of the tag (which in this case is ‘tag’)
Now you can go to https://bbpress.org/forums/profile/349081 and easily see who that is so you can probably use
get_username(349081)
or something to get the name for a mouse over. I don’t know of a way to parse the tag ID number, though.Modified: trunk/bb-admin/admin-ajax.php (2016 => 2017)
Fix adding of existing tags to a post via AJAX. Tags used to be added but didn’t have any UI response.
Perhaps this was the issue and not my mod (see above post). Not tested it out yet…
It’s also technically possible to take tag creation privileges away from specific users entirely (but then they could just sign up for a new account to get around it).
yes. that update solved the issue of the tags not appearing immediately.
thanks tom – it did indeed. nice to have that little issue fixed!
- You must be logged in to reply to this topic.