BP_Groups_Member_Suggestions::validate()

Validate and sanitise the parameters for the suggestion service query.

Description

Return

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

Source

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

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
public function validate() {
    $this->args['group_id'] = (int) $this->args['group_id'];
 
    /**
     * Filters the arguments used to validate and sanitize suggestion service query.
     *
     * @since BuddyPress 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 BuddyPress 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 );
}

Changelog

Changelog
Version Description
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.