I am honestly not remembering, is there a way to tag users in a post or anything like that. Im aware of the hashtags premium component but what Im talking about is doing like @Bryce Alfred for example and that gives a notification to that user that they were mentioned in a post.
If there isnt a component or functionality for this I might work on creating one because I think that would be a cool enhancement
Good news, I have a working prototype. Not the UI portion but if you mention users by name with the query character @ it will notifiy the users. The one problem I am facing is that I only have the knowledge to get the hook working for wall posts, not comments. Can I get some help? This is what I am using as a hook for the posts, I just need the same hook for comment creation
if (strlen($params['poster_guid']) > 0) {
ossn_add_hook("notification:add", "post:created", "com_mention_notifier");
}
else {
ossn_add_hook("notification:add", "comments:post", "com_mention_notifier");
}
but that didnt work so I dont know what to do to hook to the comments.
Also this is what I have for the payload which Im pretty sure will work once I get the hook right.
// if we have a poster guid then this is a wall post else its a comment so the payload changes. value->guid is the user we matched the @Firstname Lastname to
if (strlen($params['poster_guid']) > 0) {
$notifications->add($type, $params['poster_guid'], $params['object_guid'], $params['object_guid'], $value->guid);
}
else {
$notifications->add($type, $params['owner_guid'], $params['subject_guid'], $params['id'], $value->guid);
}
Im seeing more and more problems with this idea for a mention component where it queries/injects a name, what if there are two users with the same name? How would you distinguish between them without me loading the user image as part of the query so that you could use that to help you pick between the duplicate names. I dont know that this is something I can accomplish to be honest. In theory I know what to do but within the scope of OSSN Im not so sure how to manage the javascript/php code needed in order to do the on the fly query for users and grab the images for the users. If you guys have the patience to help me then I will give it a go but I totally get it if you dont want to help that much.
So Arsalan, I am a bit confused. Are you saying I would use @username or would I do something like @Firstname Lastname to reference a user? I guess something I am confused on as well is the UI control for the query after entering the "@" query character. I am a back end Dev by trade so this is going to be new to me. I would think since usernames are hidden from scope to most that I would be using the actual full name not username aka sign-in name. Regarding the query character would say treat it like acronym expansions or searches where you let them enter a few characters and then blow up the search string? For example, I have a user in my userbase called Maxwell Anderson and I type @Ma, nothing comes up but then I type @Max and it injects @Maxwell Anderson. Is that right? What if there are multiple Maxwell's?
Code formatting is fixed , you should be able to format code again. ossn_friend_picker
is for picking friends in wall post /tagging, however if you need to do tagging feature you need to see callback for wall post created, and comment created. Example
function my_com_init(){
ossn_register_callback('wall', 'post:created', 'wall_created');
ossn_register_callback('comment', 'created', 'comment_created');
}
function wall_created($callback, $type, $params){
$new_wall_post_id = $params['object_guid'];
$wall_post = ossn_get_object($new_wall_post_$id);
//then go through the object for post and detect @ symbol / usernames and tag and send message to users
}
function comment_created($callback, $type, $params){
//same with comment
}
Other approach should be to find some JS module that tag usernames in specific input element.
I dont know why but the code block formatting isnt working for me so sorry for the poor formatting
So upon looking into it It seems like the method below is where it needs modification but Im not sure how exactly to tap into/overrride this method because I think this is what would need to be done.
The change is in
OssnWall/ossn_com.php
function ossn_friend_picker() {
header('Content-Type: application/json');
if(!ossn_isLoggedin()) {
exit;
}
$user = new OssnUser;
$friends = $user->getFriends(ossn_loggedin_user()->guid);
if(!$friends) {
return false;
}
$search_for = input('q');
// allow case insensitivity with first typed in char
$fc = mb_strtoupper(mb_substr($search_for, 0, 1,'UTF-8'), 'UTF-8');
$search_For = $fc . mb_substr($search_for, 1, null, 'UTF-8');
// show all friends with wildcard '*' in first place
if($search_for == '*') {
$search_for = '';
$search_For = '';
}
$search_len = mb_strlen($search_for,'UTF-8');
foreach($friends as $users) {
$first_name_start = mb_substr($users->first_name, 0, $search_len, 'UTF-8');
if($first_name_start == $search_for || $first_name_start == $search_For) {
$p['first_name'] = $users->first_name;
$p['last_name'] = $users->last_name;
$p['imageurl'] = ossn_site_url("avatar/{$users->username}/smaller");
$p['id'] = $users->guid;
$usera[] = $p;
}
}
echo json_encode($usera);
}
And I think the change would be to swap line 113 from this
$friends = $user->getFriends(ossn_loggedin_user()->guid);
To this
$friends = $user->getSiteUsers(['page_limit' => false]);
Is that correct? If it is, I could use some help on how to properly implement it via a new component so as not to modify the core files.
Thanks!
Bryce
I feel like such an idiot lol, the flippin button is right there to tag friends on the post. I can see your point in that it is a filtered list of only your friends. I wish I knew more about OSSN to know what to override in that search. I know its probably just doing a SQL query on your friends and would be super easy to just remove the line from the WHERE clause or a JOIN to a friends table but I dont want to modify the core files per Arsalan and Z-Mans recommendations. Help me out guys, is there a hook I could tap into here to trigger that search with a different query to the DB and override the default behavior? If there is, I wouldnt mind making a component to open up that query to the user base. I know this isnt something that would be useful for all but it would be useful for me and maybe some others too.
You can "Tag Friends" when you create a post, but you then cannot tag them in a comment within that post (I have not been able to anyways)
You can Tag FRIENDS that are in your Friends List, but you cannot tag other members that are not in your list (I have not been able to anyways)
A component or a modification of the Hashtag component that can Tag users (any user) in both Posts and Comments would be ideal..... Bearing in mind that the Hashtag component is a Premium component ...... I believe such a feature has been asked for a number of years now in one form or another (other than for "Tag friends")
If you or anyone could create a component of that nature then I am sure it would be greatly received by all where @Username would give you are choice of tagging that user...
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)