Problem: I have a Form that is used to create a new post. I also have a custom field on the User's profile that will be used to hold a URL. I would like to take the permalink URL of the new post and save it in the User URL field using the Forms API cred_submit_complete.
Solution: Use update_user_meta to set the value of a User custom field. Use get_permalink to get the permalink of the new post that was just created.
add_action('cred_submit_complete', 'after_save_data_form_529',10,2); function after_save_data_form_529($post_id, $form_data) { if ($form_data['id']==529) { $user_id = get_current_user_id(); $permalink = get_permalink($post_id); update_user_meta( $user_id, 'wpcf-post-slug', $permalink); } }
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_submit_complete
https://developer.wordpress.org/reference/functions/get_permalink/
https://codex.wordpress.org/Function_Reference/update_user_meta
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.
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 4 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 6 Jahren, 4 Monaten.
Assistiert von: Christian Cox.