Problem: I would like to use a Form to update a custom post. When the Form is submitted, I would like to automatically set a User custom field image using the Featured Image from the Form.
Solution: Use custom code and the Forms API:
add_action('cred_save_data', 'my_save_data_action',10,2); function my_save_data_action($post_id, $form_data) { // if a specific form if ($form_data['id']==83) //can i add more than one form? { $image_value = get_the_post_thumbnail_url( $post_id, "full"); // full size, change for a different size $user = wp_get_current_user(); $user_id = $user->ID; update_user_meta($user_id, 'wpcf-profilbild', $image_value); } }
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Dieses Thema enthält 9 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 4 Jahren, 12 Monaten.
Assistiert von: Christian Cox.