Problem:
Create dynamic post title from custom fields.
Solution:
An example of how to achieve this can be seen below.
function gg_fill_full_name( $post_id, $form_data ){ if ( $form_data['id'] == 126) { $firstname = get_post_meta( $post_id, 'wpcf-first-name', true ); $middlename = get_post_meta( $post_id, 'wpcf-middle-name', true ); $lastname = get_post_meta( $post_id, 'wpcf-last-name', true ); $suffix = get_post_meta( $post_id, 'wpcf-name-suffix', true ); if ($suffix == "None") { $suffix = ''; } $result = $lastname . $suffix . ", " . $firstname . " " . $middlename; // $result = $lastname . " " . $suffix . ", " . $firstname . " " . $middlename; if ( !empty($result) ) { $my_post = array( 'ID' => $post_id, 'post_title' => $result, ); // Update the post into the database wp_update_post( $my_post, $wp_error ); } } } add_action('cred_submit_complete', 'gg_fill_full_name',10,2);
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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
Este tema contiene 24 respuestas, tiene 4 mensajes.
Última actualización por hace 6 años, 2 meses.
Asistido por: Shane.