Re: Send Private Static Message
Thanks for the pointer. Got the listener working.
Here it is, for other noobs…
`
function bp_send_private_bzzt() {
global $bp;
if ( $bp->profile->slug != $bp->current_component || ‘bzzt’ != $bp->current_action || ‘send’ != $bp->action_variables[0] )
return false;
$sender_id = $bp->action_variables[1];
$recip_id = $bp->action_variables[2];
$recip_name = htmlspecialchars(urldecode($bp->action_variables[3]));
$sender_name = $bp->loggedin_user->fullname;
$alert_message = “You just sent a BZZT! to ” . $recip_name;
bp_core_add_message( __( $alert_message, ‘buddypress’ ) );
$subject = $sender_name . ” just sent you a BZZT!”;
messages_new_message( array(‘sender_id’ => $sender_id, ‘subject’ => $subject, ‘content’ => “BZZT!”, ‘recipients’ => $recip_id ) );
bp_core_redirect( wp_get_referer() );
}
add_action( ‘wp’, ‘bp_send_private_bzzt’, 3 );
function bp_send_private_bzzt_link() {
echo bp_get_send_private_bzzt_link();
}
function bp_get_send_private_bzzt_link() {
global $bp;
if ( bp_is_my_profile() || !is_user_logged_in() )
return false;
$sender_id = $bp->loggedin_user->id;
$recip_id = $bp->displayed_user->id;
$recip_name = $bp->displayed_user->fullname;
return apply_filters( ‘bp_get_send_private_bzzt_link’, wp_nonce_url( $bp->displayed_user->domain . $bp->profile->slug . ‘/bzzt/send/’ . $sender_id . ‘/’ . $recip_id . ‘/’ . $recip_name . ‘/’) );
}
`