Saltar navegación

[Resuelto] Issue with generating permalinks and title from post form

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zona horaria del colaborador: Asia/Kolkata (GMT+05:30)

Este tema contiene 1 respuesta, tiene 1 mensaje.

Última actualización por Minesh 6 months, 1 week ago.

Asistido por: Minesh.

Autor
Mensajes
#2838007

We have a toolset post form on our site that allows users to create new "Workshops" posts (a custom post type). There are currently two issues.

1.) The title of the workshops post is supposed to be a combination of what the user enters in the "Workshop Type" and "Event Type: Subtitle" fields of the "Create a workshop" form. Right now the title is pulling the "Workshop Type" and adding it to the title correctly but not the "Event Type: Subtitle". For example, if I use the form to create a workshop with the "Workshop Type" set to "Getting the Love You Want®" and The "Event Type: Subtitle" set to " test workshop" I would expect the title to be populated as "Getting the Love You Want®: test workshop" but it is being populated as "Getting the Love You Want®: 232816"

2.) When users create workshops using the form the permalink is generated incorrectly. We need the permalink that is generated when the post is created to use the title of the post as the slug. Right now it is generating permalinks that look like this: enlace oculto

Ideally the permalink would look something like this (enlace oculto)

Let me know if you have any further questions. Thank you for any insight you can provide.

#2838111

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I'm not sure the dynamic post title you want to build is using custom field value or taxonomy term value.

However, to have such custom post title and post slug, you can use the Toolset Form hook "cred_save_data":
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

For example:

add_action('cred_save_data','func_custom_post_title',10,2);
function func_custom_post_title($post_id,$form_data) {

   if ($form_data['id']==9999) {
             $name = get_post_meta($post_id, 'wpcf-name', true);
                $email = get_post_meta($post_id, 'wpcf-email', true);
                $title= $name. '-' . $email;
                $args = array('ID' => $post_id 'post_name' => $title,
'post_title' => $title);
                wp_update_post($args);
     }
}

Where:
- You can replace the 9999 with your original form ID
- You can adjust the code as required with your original custom field slug.

You can add the above code to "Custom Code" section offered by Toolset:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#benefits-of-adding-custom-code-using-toolset