|
Types fields not updating
Started by: MikeT458
in: Types Community Support
Quick solution available
Problem: I am using cred_save_data to perform some actions after form submission, but the update_post_meta calls do not seem to be working as expected.
Solution: Check your code syntax, compare $_POST keys, and debug using the server logs.
|
|
2 |
3 |
6 years, 7 months ago
MikeT458
|
|
Use parent post title to create child post’s title with CRED
Started by: travisL-2
in: Types Community Support
Quick solution available
Problem: I am using CRED to create child posts. I would like to programmatically set the child post title based on the parent post title. I'm using the beta plugins.
Solution:
The post data key for accessing the parent post's ID has changed in the M2M betas. You can now use the format "@" + relationshipslug + "_parent". In this case the relationship slug is member_visitation, so the key is "@member_visitation_parent".
add_action('cred_save_data', 'copy_parent_title_to_child',10,2);
function copy_parent_title_to_child($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==429)
{
if (isset($_POST['@member_visitation_parent']))
{
$my_post = array(
'ID' => $post_id,
'post_title' => get_the_title($_POST['@member_visitation_parent'])
);
wp_update_post( $my_post );
}
}
}
|
|
2 |
14 |
6 years, 7 months ago
Christian Cox
|
|
Add video uploaded via CRED to post
Started by: TomT2847
in: Toolset Professional Support
Quick solution available
Problem:
I want to do is use one of the CRED API hooks after the form is submitted to add a meta value to the corresponding post.
Solution:
Yes, you are right, you can use CRED action hook "cred_save_data" to update/add custom field to the post, see the document you mentioned above:
https://toolset.com/documentation/programmer-reference/cred-api/#csd
But, it needs custom codes, for example, when user submit the CRED form, the post is saved into database, you can use hook "cred_save_data" to trigger a custom PHP function, in this function, you need to:
1) get the value of "URL of the video uploaded", if it is a custom field created with Types plugin, you can use Types function types_render_field() to get the field value:
https://toolset.com/documentation/customizing-sites-using-php/functions/
Or you can use WordPress function get_post_meta() to get the value:
https://codex.wordpress.org/Function_Reference/get_post_meta
2) use above value to update/add it to the "meta value", for example
https://developer.wordpress.org/reference/functions/update_post_meta/
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#csd
|
|
2 |
7 |
6 years, 7 months ago
TomT2847
|
|
Replacing existing email with ‘cred_notification_recipient’
Started by: tinaH
in: Toolset Professional Support
Quick solution available
Problem:
How to replace the To: recipient of a CRED notification email?
Solution:
Client is using the cred_notification_recipients filter to customise the To: recipient of a CRED notification email, but her code is *adding* another To: recipient rather than replacing the existing one.
A minor tweak of her code was required to fix the issue, as outlined below.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
|
|
2 |
3 |
6 years, 7 months ago
tinaH
|
|
CRED – using data (ID etc.) of the created post in success message
Started by: KonstantinS88
in: Toolset Professional Support
Quick solution available
Problem:
The issue here is that the user wanted to display the created post ID on their form submission message.
Solution:
Unfortunately this seems not to be possible however the user opted to redirect to the page that was created using CRED by using the following hook
//redirect after post creation
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==150) //Change this to your form's ID
//Get that Post's Permalink of Target Page
$permalink = get_permalink(130);
//Return the URL to where to redirect:
return $permalink."?created_post_id=".$post_id ;
return $url;
}
|
|
2 |
4 |
6 years, 7 months ago
KonstantinS88
|
|
File upload size limit doesn’t seem to be working
Started by: gavinS-2
in: Toolset Professional Support
Quick solution available
|
|
2 |
9 |
6 years, 7 months ago
gavinS-2
|
|
Is there a way to send both HTML and plain text email as multi-section email?
Started by: kanchunN-2
in: Toolset Professional Support
|
|
2 |
8 |
6 years, 7 months ago
Christian Cox
|
|
Notification e-mail to parent post’s author not working
Started by: amarildow
in: Toolset Professional Support
Quick solution available
Problem: I have added some custom code using the CRED API which should modify the notification email recipients list and include the parent post's author email address. It does not seem to be working.
Solution: Check the syntax and be sure your variables are correct. In this case the parent_post_author_id variable was not correctly identified with a $. The corrected code is:
/ Notification
add_filter('cred_notification_recipients', 'my_cred_notification_recipients_func', 10, 4);
function my_cred_notification_recipients_func($recipients, $notification, $form_id, $post_id){
if (204 == $form_id){
$parent_slug = "opdracht";
$field_slug = '_wpcf_belongs_' . $parent_slug . '_id';
$parent_post_id = get_post_meta($post_id, $field_slug, true);
$parent_post_author_id = get_post_field ('post_author', $parent_post_id );
$author_email = get_the_author_meta('user_email', $parent_post_author_id );
$recipients[] = array('to'=>'to', 'name'=>'', 'lastname'=>'', 'address'=>$author_email );
}
return $recipients;
}
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
|
|
2 |
5 |
6 years, 7 months ago
amarildow
|
|
Autoincrement COUNT field, function not working
Started by: pamb-2
in: Toolset Professional Support
|
|
2 |
5 |
6 years, 7 months ago
pamb-2
|
|
Custom validation on cred form with repeating field groups
Started by: jamesR-13
in: Types Community Support
Quick solution available
|
|
2 |
6 |
6 years, 8 months ago
jamesR-13
|
|
Change the placeholder text in wpv-control-distance shortcode
Started by: andyK-6
in: Toolset Professional Support
|
|
2 |
3 |
6 years, 8 months ago
andyK-6
|
|
Woocommerce + CRED : adding a featured product with a CRED
Started by: Charlie
in: Toolset Professional Support
Quick solution available
|
|
2 |
3 |
6 years, 8 months ago
Charlie
|
|
Refresh parent page after adding child post in new window
Started by: jamesR-13
in: Toolset Professional Support
|
|
3 |
10 |
6 years, 8 months ago
jamesR-13
|
|
How to set Post ID as custom field value
Started by: pamb-2
in: Toolset Professional Support
Quick solution available
|
|
2 |
16 |
6 years, 8 months ago
pamb-2
|
|
Adding Cred Forms Post title as subtitle to cart and check out page
Started by: wabw media group
in: Toolset Professional Support
|
|
2 |
5 |
6 years, 8 months ago
Christian Cox
|