bp_get_the_notification_delete_url( int $user_id )

Return the URL used for deleting a single notification.

Description

Parameters

$user_id

(int) (Required) The user ID.

Return

(string)

Source

File: bp-notifications/bp-notifications-template.php

	function bp_get_the_notification_delete_url( $user_id = 0 ) {
		// Set default user ID to use.
		$user_id = 0 === $user_id ? bp_displayed_user_id() : $user_id;

		// URL to add nonce to.
		if ( bp_is_current_action( 'unread' ) ) {
			$link = bp_get_notifications_unread_permalink( $user_id );
		} elseif ( bp_is_current_action( 'read' ) ) {
			$link = bp_get_notifications_read_permalink( $user_id );
		}

		// Get the ID.
		$id = bp_get_the_notification_id();

		// Get the args to add to the URL.
		$args = array(
			'action'          => 'delete',
			'notification_id' => $id
		);

		// Add the args.
		$url = add_query_arg( $args, $link );

		// Add the nonce.
		$url = wp_nonce_url( $url, 'bp_notification_delete_' . $id );

		/**
		 * Filters the URL used for deleting a single notification.
		 *
		 * @since BuddyPress 2.1.0
		 * @since BuddyPress 2.6.0 Added $user_id as a parameter.
		 *
		 * @param string $url     URL used for deleting a single notification.
		 * @param int    $user_id The user ID.
		 */
		return apply_filters( 'bp_get_the_notification_delete_url', $url, $user_id );
	}

Changelog

Changelog
Version Description
BuddyPress 2.6.0 Added $user_id as a parameter. BuddyPress 2.6.0 Added $user_id as a parameter.
BuddyPress 2.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.