BBP_User_Engagements_User::remove_user_from_all_objects( int $user_id, string $meta_key = '', string $meta_type = 'post' )

Remove a user id from all objects


Description Description


Parameters Parameters

$user_id

(Required) The user id

$meta_key

(Optional) The relationship key

Default value: ''

$meta_type

(Optional) The relationship type (usually 'post')

Default value: 'post'


Top ↑

Return Return

(bool) Returns true on success, false on failure


Top ↑

Source Source

File: includes/common/engagements.php

	public function remove_user_from_all_objects( $user_id = 0, $meta_key = '', $meta_type = 'post' ) {

		// Get the key
		$option_key = $this->get_user_option_key( $meta_key );

		// Get the option
		$object_ids = $this->parse_comma_list( get_user_option( $option_key, $user_id ) );

		// Attempt to delete the user option
		$retval = delete_user_option( $user_id, $option_key );

		// Try to delete caches, but only if everything else succeeded
		if ( ! empty( $retval ) && ! empty( $object_ids ) ) {
			foreach ( $object_ids as $object_id ) {
				$this->cache_delete( $meta_key, $object_id );
			}
		}

		// Return true if user was removed, or false if not
		return $retval;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.