I was wondering if anyone knew how to set up the buddypress notifications, such as :
-Activity Comments
-New Likes
-New Activity
-Gifts
-New Forum reply
But the most important are:
-New Messages
-New Friend Requests
Stand-Alone or Non-Included Notifications
In order for site notifications to function correctly, you must insert a mySQL query where the action occurs on your site. For example, if you want your users to receive notifications for private messages, you need to insert the statement whenever a private message is sent. An example mySQL query would be:
- Code: Select all
$sql = "INSERT INTO arrowchat_notifications (to_id, author_id, author_name, type, alert_time)
VALUES ('".$to_id."', '".$author_id."', '".$author_name."', '1', '".time()."')";
mysql_query($sql);
If the notification does not have an author id or author name, you can leave those blank or null, or you can use those fields for different information.
to_id - (int) The user ID of the user that should receive the notification.
author_id - (int) The user ID of the user that sent the notification. Can be left blank if none.
author_name - (varchar) The name of the user that sent the notification. Can be left blank if none.
misc1 - (varchar) Optional, use this field for any additional information.
misc2 - (varchar) Optional, use this field for any additional information.
misc3 - (varchar) Optional, use this field for any additional information.
type - (int) The type of notification. You need to create a notification markup in the admin panel, and then insert the number of that markup as the type.
alert_time - (int) The unix time of when the notification was sent.
AKaczorowski wrote:Just found documentation on the Install Guide. (Step 5)Stand-Alone or Non-Included Notifications
In order for site notifications to function correctly, you must insert a mySQL query where the action occurs on your site. For example, if you want your users to receive notifications for private messages, you need to insert the statement whenever a private message is sent. An example mySQL query would be:
- Code: Select all
$sql = "INSERT INTO arrowchat_notifications (to_id, author_id, author_name, type, alert_time)
VALUES ('".$to_id."', '".$author_id."', '".$author_name."', '1', '".time()."')";
mysql_query($sql);
If the notification does not have an author id or author name, you can leave those blank or null, or you can use those fields for different information.
to_id - (int) The user ID of the user that should receive the notification.
author_id - (int) The user ID of the user that sent the notification. Can be left blank if none.
author_name - (varchar) The name of the user that sent the notification. Can be left blank if none.
misc1 - (varchar) Optional, use this field for any additional information.
misc2 - (varchar) Optional, use this field for any additional information.
misc3 - (varchar) Optional, use this field for any additional information.
type - (int) The type of notification. You need to create a notification markup in the admin panel, and then insert the number of that markup as the type.
alert_time - (int) The unix time of when the notification was sent.
remove_action( 'wp_ajax_post_update', 'bp_dtheme_post_update' );
//add our own handler for activity posting
add_action( 'wp_ajax_post_update', 'bp_mytheme_post_update' );
/* AJAX update posting */
function bp_mytheme_post_update() {
global $bp, $wpdb;
/* Check the nonce */
check_admin_referer( 'post_update', '_wpnonce_post_update' );
if ( !is_user_logged_in() ) {
echo '-1';
return false;
}
if ( empty( $_POST['content'] ) ) {
echo '-1<div id="message"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>';
return false;
}
if ( empty( $_POST['object'] ) && function_exists( 'bp_activity_post_update' ) ) {
//this is what I have changed
if(!bp_is_home()&&bp_is_member())
$content="@". bp_get_displayed_user_username()." ".$_POST['content'];
else
$content=$_POST['content'];
$activity_id = bp_activity_post_update( array( 'content' => $content ) );
//end of my changes
} elseif ( $_POST['object'] == 'groups' ) {
if ( !empty( $_POST['item_id'] ) &&function_exists( 'groups_post_update' ) )
$activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) );
} else
$activity_id = apply_filters( 'bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content'] );
if ( !$activity_id ) {
echo '-1<div id="message"><p>' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '</p></div>';
return false;
}else{
if($bp->current_component == 'wall' && $bp->displayed_user->id !=$bp->loggedin_user->id){
$sql = "INSERT INTO arrowchat_notifications (to_id, author_id, author_name, type, alert_time, misc1, misc2)
VALUES (".$bp->displayed_user->id.", ".$bp->loggedin_user->id.",'".ucfirst(xprofile_get_field_data('First Name',$bp->loggedin_user->id))." ".ucfirst(xprofile_get_field_data('Last Name',$bp->loggedin_user->id)) ."',3,".time().",'".$bp->displayed_user->userdata->user_url ."','".$bp->loggedin_user->userdata->user_url ."')";
$wpdb->query($sql);
//echo $sql;
}
}
if ( bp_has_activities ( 'include=' . $activity_id ) ) : ?>
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<?php locate_template( array( 'activity/entry.php' ), true ) ?>
<?php endwhile; ?>
<?php endif;
}