Heartbeat
About this demo
Activity streams
Groups
Documentation
FAQ
Downloads
Examples
Heartbeat
Languages
Nederlands
English
Home
Custom code for flag activity
This is an example of how to log activity through code for a user, flagging some content.
PHP Code
Code:
/**
* Implementation of hook_flag(). Trigger actions if any are available.
*/
function
hbi_flag
(
$action
,
$flag
,
$content_id
,
$account
)
{
// Follow another user
if
(
$action
==
'flag'
&&
$flag
-
>
content_type
==
'user'
&&
$flag
-
>
name
==
'follow'
)
{
$message_id
=
'heartbeat_follow_user'
;
$variables
=
array
(
'@user1'
=
>
l
(
$account
-
>
name
,
'user/'
.
$account
-
>
uid
)
,
'@user2'
=
>
l
(
user_load
(
$content_id
)
-
>
name
,
'user/'
.
$content_id
)
,
)
;
heartbeat_api_log
(
$message_id
,
$account
-
>
uid
,
$content_id
, 0, 0,
$variables
)
;
}
// Become a fan of another user
if
(
$action
==
'flag'
&&
$flag
-
>
content_type
==
'user'
&&
$flag
-
>
name
==
'fan'
)
{
$message_id
=
'heartbeat_flag_userfan_add'
;
$variables
=
array
(
'@user1'
=
>
l
(
$account
-
>
name
,
'user/'
.
$account
-
>
uid
)
,
'@user2'
=
>
l
(
user_load
(
$content_id
)
-
>
name
,
'user/'
.
$content_id
)
,
)
;
heartbeat_api_log
(
$message_id
,
$account
-
>
uid
,
$content_id
, 0, 0,
$variables
)
;
}
}
1
2
3
next ›
last »
Guideline
Installing heartbeat module
Short step-by-step guideline
Heartbeat implementations
Activity streams
Activity within a group
Tutorials and examples
Creating first activity logs
Adding custom tokens
How to create a heartbeat activity view for a single group
Facebook status example
Adding user avatar in stream
Code snippets
Logging activity of insert and update node
Custom code for flag activity
Log friends activity
Using realname module
F.A.Q's
Hooks
hook_heartbeat_message_info
hook_heartbeat_register_access_types
hook_heartbeat_messages_alter
hook_heartbeat_theme_alter
hook_heartbeat_stream_filters
hook_heartbeat_attachments
User login
Username:
*
Password:
*
Request new password