• Resolved MiguelAguilera

    (@miguelaguilera)


    Hi, i have a problem when designing my web. I’m trying to create a form that allows bringing one companion. They have to choose between some activities, those activities have limited access. I’ve managed to count them separately, but i need that when you select one(either user or companion), it affects the total counter.

    My code looks like this:

    if($posted_field->id == 764 and !is_admin()){
    global $wpdb;
    $entry_id = (isset($_POST[‘id’])) ? $_POST[‘id’] : 0;
    $entries = $wpdb->get_col($wpdb->prepare(“SELECT item_id FROM “. $wpdb->prefix .”frm_item_metas em LEFT JOIN “. $wpdb->prefix .”frm_items e ON (em.item_id = e.id) WHERE em.field_id=%d AND em.meta_value=%s AND item_id != %d”, $posted_field->id, $_POST[‘item_meta’][$posted_field->id], $entry_id));

    //Trying to acces the other field database NOT WORKING
    $entry_id_acompañante = (isset($_POST[‘772’])) ? $_POST[‘772’] : 0;
    $entriesacompañante = $wpdb->get_col($wpdb->prepare(“SELECT item_id FROM “. $wpdb->prefix .
    “frm_item_metas em LEFT JOIN “. $wpdb->prefix .”frm_items e ON (em.item_id = e.id)
    WHERE em.field_id=%d AND em.meta_value=%s AND item_id != %d”,
    772, $_POST[‘item_meta’][772], $entry_id_acompañante));

    if(count($entries) + count($entriesacompañante) >= 2)
    $errors[‘field’. $posted_field->id] = ‘Ya no quedan plazas disponibles para esta hora.’;

    //$_POST[‘item_meta’][772] = $_POST[‘item_meta’][764];
    }

    Thanks

    https://ww.wp.xz.cn/plugins/formidable/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Creating two fields that share a counter(formidable)’ is closed to new replies.