/**
  * 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['only_friends'] = (bool) $this->args['only_friends'];
     /**
      * Filters the members suggestions args for the current user.
      *
      * @since 2.1.0
      *
      * @param array                  $args Array of arguments for the member suggestions.
      * @param BP_Members_Suggestions $this Current BP_Members_Suggestions instance.
      */
     $this->args = apply_filters('bp_members_suggestions_args', $this->args, $this);
     // Check for invalid or missing mandatory parameters.
     if ($this->args['only_friends'] && (!bp_is_active('friends') || !is_user_logged_in())) {
         return new WP_Error('missing_requirement');
     }
     /**
      * Filters the validation status for the suggestion service query.
      *
      * @since 2.1.0
      *
      * @param bool|WP_Error          $value Results of validation check.
      * @param BP_Members_Suggestions $this  Current BP_Members_Suggestions instance.
      */
     return apply_filters('bp_members_suggestions_validate_args', parent::validate(), $this);
 }
Esempio n. 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['only_friends'] = (bool) $this->args['only_friends'];
		$this->args                 = apply_filters( 'bp_members_suggestions_args', $this->args, $this );

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

		return apply_filters( 'bp_members_suggestions_validate_args', parent::validate(), $this );
	}
Esempio n. 3
0
 /**
  * Validate and sanitize the parameters for the suggestion service query.
  *
  * @package WP Idea Stream
  * @subpackage buddypress/groups
  *
  * @since  2.0.0
  *
  * @uses   sanitize_key() to sanitize the meta key
  * @uses   sanitize_text_field() to sanitize the meta value
  * @uses   wp_idea_stream_user_can() to check for user's capability
  * @uses   is_user_logged_in() to be extra sure the user is logged in
  * @uses   apply_filters() Calls 'wp_idea_stream_groups_suggestions_args' to do extra sanitization
  *                         Calls 'wp_idea_stream_groups_suggestions_validate_args' to override the validation result
  * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
  */
 public function validate()
 {
     $this->args['show_hidden'] = (bool) $this->args['show_hidden'];
     $this->args['meta_key'] = sanitize_key($this->args['meta_key']);
     $this->args['meta_value'] = sanitize_text_field($this->args['meta_value']);
     $this->args['author'] = absint($this->args['author']);
     /**
      * @param array $this->args the arguments to do extra sanitization
      * @param WP_Idea_Stream_Groups_Suggestions $this the current class
      */
     $this->args = apply_filters('wp_idea_stream_groups_suggestions_args', $this->args, $this);
     // Check for invalid or missing parameters.
     if ($this->args['show_hidden'] && (!wp_idea_stream_user_can('edit_ideas') || !is_user_logged_in())) {
         return new WP_Error('missing_requirement');
     }
     /**
      * @param bool    true if success, false otherwise
      * @param WP_Idea_Stream_Groups_Suggestions $this the current class
      */
     return apply_filters('wp_idea_stream_groups_suggestions_validate_args', parent::validate(), $this);
 }