Okay. Thank you
I need to read ore on that
I need further help as a newbie. Please help me get this done.T_T Reality: I have four options in a drop down. (ie Adzotor, Xalavia, Gbogbi, Gbekor) Kindly edit the code and paste here to auto assign any of this Houses based on this sequence (Adzotor, Xalavia, Gbogbi, Gbekor) per submission. I have tried but to no avail
Sorry, but this forum isn't really about writing code for people. I suggest you reach out to a developer to help - https://formidable-masterminds.com/developers-directory/
Here's some sample code from the Formidable Forms documentation That I've adapted below as a starting point. Hope it helps.
https://formidableforms.com/knowledgebase/frm_validate_field_entry/#kb-round-robin-assignments
A potential solution could be based on a "round robin" method where some custom code assigns the house The code provided here is adapted from the "Round robin assignments" example in the Formidable Forms documentation for its built-in frm_validate_field_entry function 1. Create a read-only text field with a default value of [auto_id]. Note the field ID. 2. Set that field visibility to admin-only in the advanced settings 3. Create another admin-only text field where the house name is stored. Note the field ID. 4. Use the following code snippet in either a code snippet plugin or the site's function.php, and change the values where noted in the code's comments to suit your needs. 5. Create Views for tracking the entries and for sending out housing assignment notifications, or for use in form Confirmation settings.
add_filter( 'frm_validate_field_entry', 'frm_set_house_based_on_order', 15, 3 ); function frm_set_house_based_on_order( $errors, $posted_field, $posted_value ) { if ( $posted_field->id == 175 ) { //change 175 to the ID of your house name field $house_id = $_POST['item_meta'][174] % 4;//change 174 to your auto_id field and 4 to the number of houses you have $house_name = "unassigned";//change "unassigned" to your default value switch ( $house_id ) { case 0: $house_name = "house-01";//change "house-01" to the name of your house break; case 1: $house_name = "house-02";//change "house-02" to the name of your house break; case 2: $house_name = "house-03";//change "house-03" to the name of your house break; case 3: $house_name = "house-04";//change "house-04" to the name of your house break; }//add additional cases for additional groups, as you'd like $_POST['item_meta'][175] = $house_name;//change 175 to the ID of your house name field } return $errors; }
sorry for the wierd formatting, I can't get the text field in this forum to make line breaks :pouting:
When posting code blocks, it's easier to post on pastebin or gist and include the link here.
Please login or Register to submit your answer