BuddyDev

Search

Question – Plugin Moderation, where it's set this

Tagged: 

  • Participant
    Level: Master
    Posts: 251
    MICHAEL on #22462

    Hi again, =P

  • Participant
    Level: Master
    Posts: 251
    MICHAEL on #22463
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #22484

    Hi Michaël,
    I will post a snippet later. There is a hook that allows you to do it.

    
    bpmts_form_field_validation_message
    

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 251
    MICHAEL on #22492
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #22515

    Hi Michaël,

    Here is an example.

    
    
    /**
     * Custom validation for BuddyPress moderation tools.
     *
     * @param string $err error message if any.
     * @param string $field field name.
     * @param mixed $value field value.
     *
     * @return string
     */
    function buddydev_custom_moderation_validation( $err, $field, $value ) {
    
    	// $field could be 'subject', 'message', 'category', 'name', 'email'
    
    	switch ( $field ) {
    
    		case 'message':
    			// validate and if error, set to $err.
    			if ( strlen( $value ) > 500 ) {
    				$err = "Only 500 charaters allowed.";
    			}
    			break;
    		case 'subject':
    			// if subject is longer than 50 character.
    			if ( strlen( $value ) > 50 ) {
    				$err = "Subject is too long. Only 50 letters allowed.";
    			}
    			break;
    
    	}
    
    	return $err;
    }
    
    add_filter( 'bpmts_form_field_validation_message', 'buddydev_custom_moderation_validation', 10, 3 );
    
    

    Please change the values as you please.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 251
    MICHAEL on #22524
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #22563
    This reply has been marked as private.
  • Participant
    Level: Master
    Posts: 251
    MICHAEL on #22569
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #22576
    This reply has been marked as private.
  • Participant
    Level: Master
    Posts: 251
    MICHAEL on #22583
    This reply has been marked as private.

You must be logged in to reply to this topic.

This topic is: not resolved