Howdy . . . copy and paste coder needs help :)

By: Jason Ryan | Asked: 05/31/2023
ForumsCategory: Code HelpHowdy . . . copy and paste coder needs help :)
Jason Ryan asked 11 months ago

Hi all, my names Jason, I'm creating a site to organise work for our engineers.

I created a drop-down on my "Job Entry" form that had 3 options and was able to style it based on the content of the entry using another tutorial.

“Completed” goes green,  “Partially Completed” goes orange, and “Needs Completed” is shown in red.

Creating a second form for the Engineer to fill out a "Job Completion" Report This form updates the drop-down status in the original creation forms entries, using this code found in another tutorial, see below :

Start your code here
add_action('frm_after_create_entry', 'link_fields', 30, 2); add_action('frm_after_update_entry', 'link_fields', 10, 2); function link_fields($entry_id, $form_id){ if($form_id == 2){//Change 2 to the ID of the first form global $wpdb; $first_field = $_POST['item_meta'][274]; //change 274 to the ID of the field in your first form $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM ". $wpdb->prefix ."frm_items WHERE id=%d", $entry_id)); $entry_ids = $wpdb->get_col("Select id from ". $wpdb->prefix ."frm_items where form_id='6' and user_id=". $user);//Change 6 to the ID of the second form foreach ($entry_ids as $e) $wpdb->update( $wpdb->prefix .'frm_item_metas', array('meta_value' => $first_field), array('item_id' => $e, 'field_id' => '121'));//Change 121 to the ID of the field to be updated automatically in your second form } }

Using the above I got one form to update the other. But it updated every entry under that user.
I’m presuming that I need to do a check somehow to match “Job entries” and “Job updates”.  

Update only entries where       'field_id' => '113'     from      form_id='6'          matches         'field_id' => '110'       from      form_id='2'               

Is there any way to add that check, to the above code?  Sorry, I’m not .php literate and only have a logical and very basic understanding of the above code. Any help you could give me with this, I would really appreciate.

Rob LeVineRob LeVine replied 11 months ago

Yes it's quite possible to do this and I started typing a response but then realized that if you PHP skills are not at least intermediate, my answer won't serve you. I suggest you reach out to someone on the Formidable Masterminds directory who can help you.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community