BP_Groups_Member_Suggestions::validate()

Validate and sanitise the parameters for the suggestion service query.


Description Description


Return Return

(true|WP_Error) If validation fails, return a WP_Error object. On success, return true (bool).


Top ↑

Source Source

File: bp-groups/classes/class-bp-groups-member-suggestions.php

	public function validate() {
		$this->args['group_id'] = (int) $this->args['group_id'];

		/**
		 * Filters the arguments used to validate and sanitize suggestion service query.
		 *
		 * @since 2.1.0
		 *
		 * @param array                        $args  Array of arguments for the suggestion service query.
		 * @param BP_Groups_Member_Suggestions $this  Instance of the current suggestion class.
		 */
		$this->args             = apply_filters( 'bp_groups_member_suggestions_args', $this->args, $this );

		// Check for invalid or missing mandatory parameters.
		if ( ! $this->args['group_id'] || ! bp_is_active( 'groups' ) ) {
			return new WP_Error( 'missing_requirement' );
		}

		// Check that the specified group_id exists, and that the current user can access it.
		$the_group = groups_get_group( absint( $this->args['group_id'] ) );

		if ( $the_group->id === 0 || ! $the_group->user_has_access ) {
			return new WP_Error( 'access_denied' );
		}

		/**
		 * Filters the validation results for the suggestion service query.
		 *
		 * @since 2.1.0
		 *
		 * @param bool|WP_Error                $value True if valid, WP_Error if not.
		 * @param BP_Groups_Member_Suggestions $this  Instance of the current suggestion class.
		 */
		return apply_filters( 'bp_groups_member_suggestions_validate_args', parent::validate(), $this );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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