Jump to content

CraigMcKee

New Members
  • Content Count

    7
  • Joined

  • Last visited

Everything posted by CraigMcKee

  1. I have it working but of course now have two further questions... 1 - how can I get the value from field id 9 and 2 - how can I return all this information now using shortcode rather than echo? add_filter('frm_after_display_content', 'add_view_total_to_after_content', 30, 4); function add_view_total_to_after_content($after_content, $display, $show, $atts){ $entries = $atts['entry_ids']; for ($x = 1; $x <= 10; $x++) { $ridername = ""; foreach($entries as $entry){ if ($x == FrmProEntriesController::get_field_value_shortcode(array( 'field_id' => 6, 'entry' => $entry ))) { $ridernumber = $x; $ridername = (FrmProEntriesController::get_field_value_shortcode(array( 'field_id' => 7, 'entry' => $entry))); } } if ($ridername == "") {echo "$x - br";} if ($ridername != "") {echo "$ridernumber - $ridername br";} } }
  2. I'm so close to this working!! I have this code: add_filter('frm_after_display_content', 'add_view_total_to_after_content', 30, 4); function add_view_total_to_after_content($after_content, $display, $show, $atts){ $entries = $atts['entry_ids']; for ($x = 1; $x <= 10; $x++) { foreach($entries as $entry){ if ($x == FrmProEntriesController::get_field_value_shortcode(array( 'field_id' => 6, 'entry' => $entry ))) { echo "$x - Rider match "; echo (FrmProEntriesController::get_field_value_shortcode(array( 'field_id' => 7, 'entry' => $entry))); } else { } } echo "$x - <br>"; } } But it displays repeated numbers after printing values in the form: 1 - Rider match Laurie1 - 2 - 3 - 4 - 5 - 6 - Rider match Craig McKee6 - 7 - 8 - 9 - 10 - Where have I gone wrong in my loop?
  3. Ah ok, sorry. Code that removes used items from drop down: add_filter('frm_setup_edit_fields_vars', 'frm_remove_selected', 20, 2); add_filter('frm_setup_new_fields_vars', 'frm_remove_selected', 20, 2); function frm_remove_selected($values, $field){ if ( in_array( $field->id ==6, array(range(0,60)) ) ) { $used = FrmEntryMeta::get_entry_metas_for_field( $field->id ); if ( $used ) { $used_vals = array(); foreach ( $used as $u ) { if ( is_array( $u ) ) { foreach ( $u as $item ) { $used_vals[] = $item; unset($item); } } else { $used_vals[] = $u; } unset($u); } if ( $field->type == 'data' ) { foreach ( $used_vals as $u ) { if ( isset($values['options'][$u]) ) { unset($values['options'][$u]); } unset($u); } } else { $values['options'] = array_diff( $values['options'], $used_vals ); } } } return $values; } And code that returns a total of rider numbers (largely useless but at least I know I can get it to return something!) add_filter('frm_after_display_content', 'add_view_total_to_after_content', 30, 4); function add_view_total_to_after_content($after_content, $display, $show, $atts){ if ( $display->ID == 145 ) { $entries = $atts['entry_ids']; $total = 0; foreach($entries as $entry){ $current_value = FrmProEntriesController::get_field_value_shortcode(array( 'field_id' => 6, 'entry' => $entry ) ); if ( $current_value ) { $total += $current_value; } } $after_content = str_replace('[sum_6]', $total, $after_content); } return $after_content; } What I need to do is get the second code to loop through all items in the drop down (field id 6) irrelevant of whether they have been selected and return drop down number (field id 6) and rider name (field id 7). Does that make sense?
  4. The username is stored in field id 7 if that is needed!
  5. Hi, I'm so close to having this work how I want but one last thing! I have a form with a drop down box with the numbers 1 - 60 in. I have created a view that returns any numbers people have submitted with their login names, e.g. 1 - Laurie 4 - Craig What I need to happen is it to list all the empty numbers too, so like this: 1 - Laurie 2 - 3 - 4 - Craig 5 - etc This code removes numbers that have already been selected from the drop down box (so after Laurie and Craig had chosen 1 & 4 the drop down box would now show 2, 3, 5, 6 etc) https://pastebin.com/dAps0kqJ and this code subtotals the rider numbers (I was just trying to get a custom view to work so am pleased this returns something) https://pastebin.com/A7MwSQ2S Using the first code how do I edit the second code so that it displays every number whether a user has chosen it or not? Thank you!!
  6. Thank you - you were in the right place - I changed that array to range(1-60) and that's done the trick thank you.
  7. Hello, I'm sorry, I know nothing about php programming but need some help - I'm sure this will be a simple question! I have created a Formidable form on Wordpress (form is named BookingTest). It has a drop down box on (called dropdown) that has a list of numbers that requires a unique value. The plugin designers have shared some code that is supposed to remove used values from the drop down box but it's not working - I don't know if I've put it in the right place or if I need to edit it or anything like that. This is there documentation: https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/?fbclid=IwAR1Zj1jWo6iqdR4Cjq8MGpTLRW01XToPR7vp_2oN4XEmQ81SLAW-sbtbYKU#kb-remove-used-options I have pasted this code in it's entirety to a Code Snippets plugin but I still get all the values appear. Do I need to amend it to refer to my form explicitly? How is this filter called? Do I need to add an action?! Really confused :( Thank you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.