Cost field validation rules

Home Forums Calendar Products Events Calendar PRO Cost field validation rules

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1087810
    Keith
    Participant

    Hi,

    What are the validation rules for the cost field? It accepts 10-20 for example. “From 20” seems to be converted to 20. “5,10,15” is converted to 15.

    Is there anyway to modify that field to accept text strings without modifying them, to just print them verbatim?

    #1087911
    George
    Participant

    Hey @Keith,

    By default the cost field tries to limit values to “Free”, or to integers specifically. It does this rather aggressively—to try and allow any string as-is, I would recommend adding this code to your theme’s functions.php file:


    add_filter( 'tribe_get_cost', 'cost_show_full_meta_field', 10, 2 );

    function cost_show_full_meta_field( $cost, $post_id ) {
    $full_cost = tribe_get_event_meta( $post_id, '_EventCost', false );

    if ( isset( $full_cost[0] ) ) {
    return sanitize_text_field( $full_cost[0] );
    }

    return $cost;
    }

    Let me know if this helps!
    George

    #1094415
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Cost field validation rules’ is closed to new replies.