bp_legacy_theme_mark_activity_favorite()
Mark an activity as a favourite via a POST request.
Description Description
Return Return
(string|null) HTML
Source Source
File: bp-templates/bp-legacy/buddypress-functions.php
function bp_legacy_theme_mark_activity_favorite() { // Bail if not a POST action. if ( ! bp_is_post_request() ) { return; } if ( ! isset( $_POST['nonce'] ) ) { return; } // Either the 'mark' or 'unmark' nonce is accepted, for backward compatibility. $nonce = wp_unslash( $_POST['nonce'] ); if ( ! wp_verify_nonce( $nonce, 'mark_favorite' ) && ! wp_verify_nonce( $nonce, 'unmark_favorite' ) ) { return; } $activity_id = (int) $_POST['id']; $activity_item = new BP_Activity_Activity( $activity_id ); if ( ! bp_activity_user_can_read( $activity_item, bp_loggedin_user_id() ) ) { return; } if ( bp_activity_add_user_favorite( $_POST['id'] ) ) _e( 'Remove Favorite', 'buddypress' ); else _e( 'Favorite', 'buddypress' ); exit; }
Changelog Changelog
Version | Description |
---|---|
1.2.0 | Introduced. |