예제 #1
0
/**
 * Remove a screen notification for a user.
 */
function bp_em_remove_screen_notifications()
{
    global $bp;
    if (function_exists('bp_notifications_delete_notifications_by_type')) {
        //backwards compat for BP 1.9
        bp_notifications_delete_notifications_by_type($bp->loggedin_user->id, $bp->events->slug, 'attending');
    } else {
        bp_core_delete_notifications_by_type($bp->loggedin_user->id, $bp->events->slug, 'attending');
    }
}
예제 #2
0
/**
 * bp_em_screen_two()
 *
 * Sets up and displays the screen output for the sub nav item "em/screen-two"
 */
function bp_em_my_bookings()
{
    global $bp, $EM_Event;
    //assume any notifications here are considered viewed via this page
    if (function_exists('bp_notifications_delete_notifications_by_type')) {
        bp_notifications_delete_notifications_by_type(get_current_user_id(), 'events', 'pending_booking');
        bp_notifications_delete_notifications_by_type(get_current_user_id(), 'events', 'confirmed_booking');
        bp_notifications_delete_notifications_by_type(get_current_user_id(), 'events', 'cancelled_booking');
    } else {
        bp_core_delete_notifications_by_type(get_current_user_id(), 'events', 'pending_booking');
        bp_core_delete_notifications_by_type(get_current_user_id(), 'events', 'confirmed_booking');
        bp_core_delete_notifications_by_type(get_current_user_id(), 'events', 'cancelled_booking');
    }
    em_load_event();
    /**
     * If the user has not Accepted or Rejected anything, then the code above will not run,
     * we can continue and load the template.
     */
    do_action('bp_em_my_bookings');
    add_action('bp_template_title', 'bp_em_my_bookings_title');
    add_action('bp_template_content', 'bp_em_my_bookings_content');
    /* Finally load the plugin template file. */
    bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
}
예제 #3
0
/**
 * Delete notifications the user received in case his account was deleted
 *
 * @package WP Idea Stream
 * @subpackage buddypress/notifications
 *
 * @since  2.0.0
 *
 * @param  int $user_id the deleted user id
 * @uses   bp_notifications_delete_notifications_by_type() to delete the notifications
 * @uses   buddypress() to get BuddyPress instance
 */
function wp_idea_stream_buddypress_delete_all_user_notifications($user_id = 0)
{
    if (empty($user_id)) {
        return false;
    }
    // Delete all user's notifications
    return bp_notifications_delete_notifications_by_type($user_id, buddypress()->ideastream->id, '');
}
/**
 * Delete notifications for a user by type
 *
 * Used when clearing out notifications for a specific component when the user
 * has visited that component.
 *
 * @deprecated Deprecated since BuddyPress 1.9.0. Use
 *  bp_notifications_delete_notifications_by_type() instead.
 *
 * @since BuddyPress (1.0)
 * @param int $user_id
 * @param string $component_name
 * @param string $component_action
 * @return boolean True on success, false on fail
 */
function bp_core_delete_notifications_by_type($user_id, $component_name, $component_action)
{
    // Bail if notifications is not active
    if (!bp_is_active('notifications')) {
        return false;
    }
    // Trigger the deprecated function notice
    _deprecated_function(__FUNCTION__, '1.9', 'bp_notifications_delete_notifications_by_type()');
    return bp_notifications_delete_notifications_by_type($user_id, $component_name, $component_action);
}
/**
 * Delete notifications when a logged-in user visits their followers page.
 *
 * Since 1.2.1, when the "X users are now following you" notification appears,
 * users will be redirected to the new notifications unread page instead of
 * the logged-in user's followers page.  This is so users can see who followed
 * them and in the date order in which they were followed.
 *
 * For backwards-compatibility, we still keep the old method of redirecting to
 * the logged-in user's followers page so notifications can be deleted for
 * older versions of BuddyPress.
 *
 * Will probably remove this in a future release.
 *
 * @since 1.2.1
 */
function bp_follow_notifications_delete_on_followers_page()
{
    if (!isset($_GET['new'])) {
        return;
    }
    if (!is_user_logged_in()) {
        return;
    }
    // BP 1.9+
    if (bp_is_active('notifications')) {
        bp_notifications_delete_notifications_by_type(bp_loggedin_user_id(), $bp->follow->id, 'new_follow');
        // BP < 1.9
    } elseif (!class_exists('BP_Core_Login_Widget')) {
        global $bp;
        bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->follow->id, 'new_follow');
    }
}