/** * Remove compliments data for the given user id. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param int $user_id The user ID. */ function bp_compliments_remove_data($user_id) { /** * Functions hooked to this action will be processed before deleting the user's complement data. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param int $user_id The User ID. */ do_action('bp_compliments_before_remove_data', $user_id); BP_Compliments::delete_all_for_user($user_id); /** * Functions hooked to this action will be processed after deleting the user's complement data. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param int $user_id The User ID. */ do_action('bp_compliments_after_remove_data', $user_id); }
/** * Delete a single complement using compliment ID. * * @since 0.0.1 * @package BuddyPress_Compliments */ function delete_single_complement() { if (!bp_is_user()) { return; } if (!current_user_can('manage_options')) { if (bp_displayed_user_id() != bp_loggedin_user_id()) { return; } } if (!isset($_GET['c_id']) or !isset($_GET['action'])) { return; } $bp_compliment_can_delete_value = esc_attr(get_option('bp_compliment_can_delete')); $bp_compliment_can_delete = $bp_compliment_can_delete_value ? $bp_compliment_can_delete_value : 'yes'; if (current_user_can('manage_options')) { $bp_compliment_can_delete = 'yes'; } if ($bp_compliment_can_delete == 'no') { return; } $c_id = (int) strip_tags(esc_sql($_GET['c_id'])); if (!$c_id) { return; } /** * Functions hooked to this action will be processed before deleting the complement. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param int $c_id The compliment ID. */ do_action('bp_compliments_before_remove_compliment', $c_id); BP_Compliments::delete($c_id); /** * Functions hooked to this action will be processed after deleting the complement. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param int $c_id The compliment ID. */ do_action('bp_compliments_after_remove_compliment', $c_id); $redirect = bp_displayed_user_domain() . BP_COMPLIMENTS_SLUG . '/'; bp_core_redirect($redirect); }
/** * Get compliments for a given user. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param array|string $args { * Attributes of the $args. * * @type int $user_id User ID. * @type int $offset Query results offset. * @type int $limit Query results limit. * @type int $c_id Compliment ID. * * } * @return mixed|void */ function bp_compliments_get_compliments($args = '') { $r = wp_parse_args($args, array('user_id' => bp_displayed_user_id(), 'offset' => 0, 'limit' => 100, 'c_id' => false)); /** * Filters the compliment query results. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param int $r['user_id'] The user ID. * @param int $r['offset'] Query results offset. * @param int $r['limit'] Query results limit. * @param bool|int $r['c_id'] The compliment ID. */ return apply_filters('bp_compliments_get_compliments', BP_Compliments::get_compliments($r['user_id'], $r['offset'], $r['limit'], $r['c_id'])); }