SyTry
Well-known member
Hello,
I'm trying to make an add-on to add a member statistic to the notable members page :
Here is the code I got with the help of @nocte in my Listener.php :
My code_event_listener :
If someone can help me or give me some directions, thank you !
Regards, SyTry
I'm trying to make an add-on to add a member statistic to the notable members page :
Here is the code I got with the help of @nocte in my Listener.php :
PHP:
public static function decreaseFollowersCount($entity)
{
$finder = \XF::finder('XF:User')
->where('user_id', $entity->follow_user_id);
$user = $finder->fetchOne();
if ($user)
{
$user->fastUpdate('sc_user_follow', $finder->columnSqlName('sc_user_follow') . "- 1");
}
}
public static function increaseFollowersCount($entity)
{
$finder = \XF::finder('XF:User')
->where('user_id', $entity->follow_user_id);
$user = $finder->fetchOne();
if ($user)
{
$user->fastUpdate('sc_user_follow', $finder->columnSqlName('sc_user_follow') . "+ 1");
}
}
My code_event_listener :
- entity_post_save : increaseFollowersCount
- entity_post_delete : decreaseFollowersCount
- Event hint : XF\Entity\UserFollow
increaseFollowersCount
is not working but decreaseFollowersCount
is working fine.. Really weird ! If someone can help me or give me some directions, thank you !
Regards, SyTry