Home › Toolset Professional Support › [Resolved] Custom field in not updating in the reply form after CRED_Save hook.
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)
I am trying to:
In message custom field i added a field email group users and try to update this custom field after reply form submit. But the field is not updating for reply form.
I am using the same code method to update this custom field in new message form it works fine here but not in reply form.
What tried:
As the Cred_save is not working . also tried to update the field by giving the field in the reply form but this is also not working
[cred_generic_field field='wpcf-email-group-users' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[types field='email-group-users']"
}
[/cred_generic_field]
code used:
add_action( 'cred_save_data_xxxx', 'set_post_id_in_field_group_email_reply', 10, 2 );
function set_post_id_in_field_group_email_reply( $post_id, $form_data ) {
// Retrieve the parent post ID from the 'wpcf-message-to' custom field
$parent_id = get_post_meta($post_id, 'wpcf-message-to', true); // Get the parent ID from the meta field
$relationship_slug = 'xxxxxxxx';
// Get all child posts related to the parent group
$related_posts = toolset_get_related_posts(
$parent_id, // The ID of the parent post
$relationship_slug, // The relationship slug
'parent', // 'parent' means get child posts
100, // Limit (100 as an example)
0, // Offset (no offset)
[], // No additional filters
'post_id', // Get the post IDs
'child' // We're looking for child posts
);
if (!empty($related_posts)) {
$author_ids = []; // Initialize an array to store author IDs
// Loop through each related post (child post)
foreach ($related_posts as $child_id) {
// Get the author ID of the child post
$author_id = get_post_field( 'post_author', $child_id );
// Add each author ID to the array
$author_ids[] = $author_id;
}
// If there are any author IDs, update the custom field 'wpcf-email-group-users'
if (!empty($author_ids)) {
$author_ids_string = implode(',', $author_ids); // Convert the array to a comma-separated string
update_post_meta($post_id, 'wpcf-email-group-users', $author_ids_string); // Save the author IDs in the custom field
}
}
}
I checked the access and I have all permission . Please guide me on this issue.
Hello. Thank you for contacting the Toolset support.
Can you please share problem URL where I can see the form as werll as admin access details.
Please share frontend user access details as well to access the from on frontend.
Please share all required details to what users you would like to save to group custom field.
*** 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,
Thanks for the support,
The issue is resolved as I noticed I need to change the group reply form in the single template. Its work fine now.