Hi,
Here is the script I used to custom the post title when I'm creating it, but how can I make it working also with the editing form ?
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
add_action('cred_save_data', 'func_add_movie_title', 10, 2);
function func_add_movie_title($post_id, $form_data)
{
if ($form_data['id'] == 408) {
$movie_title = isset($_POST['wpcf-original-name']) ? $_POST['wpcf-original-name'] : '';
$movie_sub_title = isset($_POST['wpcf-original-sub-name']) ? $_POST['wpcf-original-sub-name'] : '';
$title = $movie_title . '-' . $movie_sub_title;
$args = array('ID' => $post_id, 'post_title' => $title);
wp_update_post($args);
}
}
Thanks for your help.
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
Hi there
What is the ID of the edit form?
You should just need to check for either the publish form (id 408) or the edit form (e.g. id 123).
Then the code would look like:
add_action('cred_save_data', 'func_add_movie_title', 10, 2);
function func_add_movie_title($post_id, $form_data)
{
if (in_array($form_data['id'], [ 408, 123]) ) { // Edit Form IDs
$movie_title = isset($_POST['wpcf-original-name']) ? $_POST['wpcf-original-name'] : '';
$movie_sub_title = isset($_POST['wpcf-original-sub-name']) ? $_POST['wpcf-original-sub-name'] : '';
$title = $movie_title . '-' . $movie_sub_title;
$args = array('ID' => $post_id, 'post_title' => $title);
wp_update_post($args);
}
}
Thank you Nigel,
Unfortunately, it does not update the names on the edit form (I chose the right ID)...
Any idea ?
Thanks for your help.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Can you please share problem URL where I can see the edit form and what fields does not updated, please share steps that should help me to see the issue.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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.
Hi Minesh.
I’m still working locally with MampPro.
How can we do then ?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
You can send me duplicator copy of your site and also give details on what page you added the edit form and steps that should help me to see the issue.
More info:
- https://toolset.com/faq/provide-supporters-copy-site/
I have set the next reply to private which means only you and I have access to it.