Hook on wall, post:created help. It's hooking on group posts, how do I filter these out?

bryce alvord Posted in Component Development 5 years ago

I have a custom component on my site that emails users when a new post is created but I'm seeing a flaw in the design now that we are wanting to start using some other functionality. I created a group tonight and posted on the group and it hit my hook below which was surprising to me as I thought the wall only meant the main wall on the news feed, not any wall. So my question is,how can I add a "filters" to this hook or make it configurable to say hook the news feed wall post created vs. hook the groups wall post created.

function post_email() {
  ossn_register_callback("wall", "post:created", "postEmailHandler");
}

Thanks,

Bryce

Replies
Indonesian Arsalan Shah Replied 5 years ago

Similar

<?php
function post_email() {
  ossn_register_callback("wall", "post:created", "postEmailHandler");
}

function postEmailHandler($callback, $type, $params) {
  $wall = ossn_get_object($params['object_guid']); 
  if($wall && $wall->type == 'user'){ 
    //will trigger for wall posts for homepage/userprofile etc not for groups 
    Do some junk here
  }
  if($wall && $wall->type == 'group' && function_exists('ossn_get_group_by_guid')){
        $group = ossn_get_group_by_guid($wall->owner_guid);
        if($group && $group->membership == OSSN_PUBLIC){
            //something for group   
        }
  }
}
us Bryce alvord Replied 5 years ago

So I had mixed results. When the group was set to closed I got no email, when the group was set to public I still got an email using the following code, any thoughts?

function post_email() {
  ossn_register_callback("wall", "post:created", "postEmailHandler");
}

function postEmailHandler($callback, $type, $params) {
  $wall = ossn_get_object($params['object_guid']); 
  if($wall && $wall->type == 'user'){ 
    //will trigger for wall posts for homepage/userprofile etc not for groups 
    Do some junk here
  }
}
Indonesian Arsalan Shah Replied 5 years ago

you may do in your postEmailHandler

$wall = ossn_get_object($params['object_guid']);
if($wall && $wall->type == 'user'){
   //will trigger for wall posts for homepage/userprofile etc not for groups
}