MLA does not have any form of conditional logic to do something like “if form id is 5 then attachment_category=wedding”. You will have to put the value, e.g., wedding, somewhere in the form so it is sent to the server when the form is submitted. You could add a dropdown control to the form with a list of values or you could define a hidden field containing a form-specific value like “wedding”. In either case, note the field id at the top of the Field Options tab, e.g. “(ID #2)”. Here’s an example of the values passed to the server from my test form:
wpforms[fields][4]:
wpforms[fields][3]:
wpforms[fields][1][first]: David
wpforms[fields][1][last]: Lingren
wpforms[fields][2]: wedding
wpforms[id]: 9762
wpforms[nonce]: f8eee17696
page_title: Form Preview
page_url: https://l.mladev/?wpforms_form_preview=9762&new_window=1
page_id: 9762
wpforms[post_id]: 9762
wpforms[submit]: wpforms-submit
wpforms[token]: e342ab73b470c09d58072cb1171bd03c
action: wpforms_submit
You can see the value I selected in my dropdown control, wpforms[fields][2]: wedding
.
Now you can define an MLA mapping rule to be applied when an image is uploaded to the Media Library:
- Go to the Settings/Media Library Assistant IPTC/EXIF/WP tab.
- Since you want to apply the rule to new items as they are uploaded, check the “Enable IPTC/EXIF Mapping when adding new media” and “Enable IPTC/EXIF Mapping when updating media metadata” boxes.
- Find the rule name that corresponds to the taxonomy you are using, e.g., Att. Categories
- Hover over the rule name and click the “Edit” rollover action.
- In the “IPTC Value” dropdown control leave the default, “- None (select a value) -” value in place.
- In the “EXIF/Template Value” text box, enter
template:([+request:wpforms.fields.2+])
. This assigns the term named in the dropdown control (or hidden field). Substitute the field id value from your form.
- In the “Priority” dropdown, select “EXIF”.
- In the “Existing Text” dropdown, select “Replace” to replace the current field content, or select “Keep” to retain any terms assigned by other means. For new uploads you can use either option.
- In the “Status” text box, select “Active”.
- Scroll down to the bottom of the screen and click “Update”.
This works well if you have only one form. If you have multiple forms you would need to ensure that the same field id is used on all forms to assign an atttachment_category or be present with an empty value. If that’s not possible, you can use the hooks MLA provides to customize the rule processing logic. For example, test the wpforms[id]: 9762
value and only look for your field if the form id matches. If you need more details on that solution, let me know.
I hope that gets you started on a solution for your application. I will leave this topic unresolved for now in case you have problems or further questions regarding the above suggestions. Thank you for your interest in the plugin.