Sauter la navigation

[Résolu] Auto complete post title based on two field values

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Auto complete post title based on two field values

Solution:

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/auto-complete-post-title-based-on-two-field-values/#post-1937941

Relevant Documentation:

This support ticket is created Il y a 3 années et 10 mois. There's a good chance that you are reading advice that it now obsolete.

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 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Ce sujet contient 5 réponses, a 2 voix.

Dernière mise à jour par AndreG3332 Il y a 3 années et 10 mois.

Assisté par: Minesh.

Auteur
Publications
#1937017

HI there,

I have a post type called participants. I need to autofill the post title based on the two values of the Surname and first name fields.
The cred form I am using is called " Add New Participant" with an id of 623
The field slug for each one Is:
student_surname and student-first-name respectively.

Here is the function i am trying to run. It does not give me any errors however the Post title default to "CRED Auto Draft 7726c74b95ac858d5ccbdd91d443f0b1" value

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

if ($form_data['id']==623) {
$surname = get_post_meta($post_id, 'wpcf-student_surname', true);
$first_name = get_post_meta($post_id, 'wpcf-student-first-name', true);
$cptitle= $surname. ' - ' . $first_name;
$args = array('ID' => $post_id, 'post_title' => $cptitle);
wp_update_post($args);
}

}

any insights would be appreciated

#1937587

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

The cred_save_data hook you shared it looks OK to me.

Can you please share the link of the page where I can see the form you added

#1937709

Hi Minesh
here is the link for the page with the form. We do have beaver builder activated on the page.
lien caché

Thank you

#1937729

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

I just see a page with header and footer. I do not see the form.

It seems I will require admin access details to see the form.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1937941

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Can you please check now: lien caché

The only thing you missed is , you have to activate the code snippet you have added to "Custom Code" section offered by Toolset. I've just activated the code snippet you added and I can see its working as expected.

Can you please confirm it works at your end as well.

#1938249

My issue is resolved now. Thank you!