gravity forms api get_entries filter with created by id

You should be able to achieve this using the Gravity Forms API in WordPress to filter entries created by a specific user (Manager A) and retrieve associated data entries.

  1. Get Manager A’s User ID:

    First, you need to get the User ID of Manager A. You can do this programmatically in WordPress. Let’s assume you have Manager A’s User ID stored in a variable called $manager_id.

  2. Query Gravity Forms Entries:

    You can use the GFAPI::get_entries function to retrieve entries that meet your criteria. In your case, you want to filter entries created by Manager A. Here’s an example of how to do this:

    $entries = GFAPI::get_entries(
        array(
            'form_id' => 1, // Replace with your form ID
            'created_by' => $manager_id,
        )
    );
    

    Replace 1 with the actual ID of your Gravity Form.

  3. Retrieve Associated Data Entries:

    Now that you have the entries created by Manager A, you can loop through them and retrieve associated data entries using the _gf_entry_meta table. Here’s how you can do it:

    $all_related_entries = array();
    
    foreach ($entries as $entry) {
        $entry_id = $entry['id'];
    
        // Query the _gf_entry_meta table to get associated data
        $data_entries = $wpdb->get_results(
            $wpdb->prepare(
                "SELECT * FROM {$wpdb->prefix}gf_entry_meta WHERE entry_id = %d",
                $entry_id
            ),
            ARRAY_A
        );
    
        // Add data entries to the result array
        $all_related_entries = array_merge($all_related_entries, $data_entries);
    }
    

    Make sure you have global access to the $wpdb object to run database queries.

  4. Display the Results:

    Now you have the entries and associated data entries in the $all_related_entries array. You can loop through this array and display the results as needed.

    foreach ($all_related_entries as $data_entry) {
        // Display the data as per your requirements
        // For example: echo $data_entry['your_field_name'];
    }
    

    Replace 'your_field_name' with the actual field name you want to display.

  5. Dropdown Selection:

    If you want to dynamically select Manager A from a dropdown, you can use a dropdown field in your Gravity Form. Then, you can modify the $manager_id variable based on the selected option.

This code should help you retrieve and display entries and associated data entries created by Manager A using the Gravity Forms API. Make sure to replace placeholders with actual values, and adjust the code to fit your specific form and field names. Hope this helps!

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)