Example #1
0
function demodata_create_wire_message($userid)
{
    global $bp;
    $message = demodata_generate_random_text(100);
    $bp->loggedin_user->id = demodata_random_user_id();
    if (function_exists("bp_wire_new_post")) {
        return bp_wire_new_post($userid, $message, "profile");
    } else {
        return bp_activity_add(array("action" => "New Demo Profile Wire Message", "content" => $message, "component" => $bp->profile->id, "type" => "activity_update", "item_id" => $userid));
    }
}
Example #2
0
/**
 * xprofile_action_new_wire_post()
 *
 * Posts a new wire post to the users profile wire. 
 * 
 * @package BuddyPress XProfile
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @uses bp_wire_new_post() Adds a new wire post to a specific wire using the ID of the item passed and the table name.
 * @uses bp_core_add_message() Adds an error/success message to the session to be displayed on the next page load.
 * @uses bp_core_redirect() Safe redirects to a new page using the wp_redirect() function
 */
function xprofile_action_new_wire_post()
{
    global $bp;
    if ($bp->current_component != $bp->wire->slug) {
        return false;
    }
    if ('post' != $bp->current_action) {
        return false;
    }
    /* Check the nonce */
    if (!check_admin_referer('bp_wire_post')) {
        return false;
    }
    if (!($wire_post_id = bp_wire_new_post($bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile->slug, false, $bp->profile->table_name_wire))) {
        bp_core_add_message(__('Wire message could not be posted. Please try again.', 'buddypress'), 'error');
    } else {
        bp_core_add_message(__('Wire message successfully posted.', 'buddypress'));
        if (!bp_is_home()) {
            /* Record the notification for the user */
            bp_core_add_notification($bp->loggedin_user->id, $bp->displayed_user->id, 'profile', 'new_wire_post');
        }
        do_action('xprofile_new_wire_post', $wire_post_id);
    }
    if (!strpos($_SERVER['HTTP_REFERER'], $bp->wire->slug)) {
        bp_core_redirect($bp->displayed_user->domain);
    } else {
        bp_core_redirect($bp->displayed_user->domain . $bp->wire->slug);
    }
}
Example #3
0
function groups_new_wire_post($group_id, $content)
{
    global $group_obj, $bp;
    /* Check the nonce first. */
    if (!check_admin_referer('bp_wire_post')) {
        return false;
    }
    $private = false;
    if ($group_obj->status != 'public') {
        $private = true;
    }
    if ($wire_post_id = bp_wire_new_post($group_id, $content, $bp->groups->slug, $private)) {
        do_action('groups_new_wire_post', $group_id, $wire_post_id);
        return true;
    }
    return false;
}