/**
  * Validate and sanitise the parameters for the suggestion service query.
  *
  * @since 2.1.0
  *
  * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
  */
 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(array('group_id' => absint($this->args['group_id']), 'populate_extras' => true));
     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);
 }
Exemple #2
0
 /**
  * Validate and sanitise the parameters for the suggestion service query.
  *
  * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
  * @since BuddyPress (2.1.0)
  */
 public function validate()
 {
     $this->args['group_id'] = (int) $this->args['group_id'];
     $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(array('group_id' => absint($this->args['group_id']), 'populate_extras' => true));
     if ($the_group->id === 0 || !$the_group->user_has_access) {
         return new WP_Error('access_denied');
     }
     return apply_filters('bp_groups_member_suggestions_validate_args', parent::validate(), $this);
 }