BuddyDev

Search

front end posting add tickbox field to form and other features

  • Participant
    Level: Enlightened
    Posts: 27
    Simon Parker on #27658

    Hi,

    I need to add some additional features to the form for front end posting.

    current form is working well but i would like to be able to add a tickbox to confirm terms and conditions aswell as possibly adding a field for tags.

    Is this possible with the front end posting plugin?

    if so could you point me to any examples please

    thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #27662

    Hi Simon,
    Thank you for the question.

    Please see

    https://buddydev.com/support/forums/topic/custom-post-fields-in-buddyblog/#post-1637

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 27
    Simon Parker on #27689

    That’s great how do I make something a required field?

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #27721

    Hi Simon,
    You may use the ‘bsfep_validate_post’ filter to add validation errors. Here is an example(I am assuming that we are looking for a input name ‘test’

    
    add_filter( 'bsfep_validate_post', function ( $err, $post_data ) {
    
    	$input_name = 'test';
    	if ( isset( $post_data[ $input_name ] ) ) {
    		// validate
    		// let us say, it did not validate, we override the $err
    		$err = array( 'message' => 'test field failed validation', 'error' => true );
    	}
    
    	return $err;
    }, 10, 2 );
    
    

    Please do know that the validation strategy is bad(It would have been much better if we had used WP_Error to allow adding multiple errors) but it is from our old days and the validation filter was included without much thought.

    I look forward to rewrite it in near future.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved