|
Saving Cred Generic Fields Data & Accessing IT
Started by: Timothy
in: Toolset Professional Support
|
|
3 |
17 |
7 years, 2 months ago
Timothy
|
|
cred_post_expiration_custom_actions
Started by: Noriko Sugiura
in: Toolset Professional Support
|
|
2 |
10 |
7 years, 2 months ago
Noriko Sugiura
|
|
How to customize error messages of the Toolset login and reset password links?
Started by: marcB-6
in: Toolset Professional Support
Quick solution available
Problem:
How can I customize the error or success messages of the Toolest login, reset passwords and so on forms?
Solution:
You can use the Custom Filter
wpv_filter_override_auth_errors
Example:
add_filter( 'wpv_filter_override_auth_errors', 'custom_wpv_override_auth_errors', 30, 3 );
function custom_wpv_override_auth_errors( $message, $class = '', $code = '' ) {
switch( $code ) {
case 'invalid_key';
$message = __( 'CUSTOM VALUE', 'wpv-views' );
break;
case 'invalidcombo';
$message = __( 'CUSTOM VALUE', 'wpv-views' );
break;
}
return $message;
}
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_override_auth_errors
|
|
2 |
14 |
7 years, 2 months ago
marcB-6
|
|
Add Parent Post Title to Child Post Title Using cred_save_data Function
Started by: julieP
in: Toolset Professional Support
Quick solution available
Problem: I have a CRED form that allows users to create child posts. Using cred_save_data, I would like to create a custom post title using information stored in a custom field on the parent post.
Solution: In cred_save_data, you will be able to determine the parent post's ID using get_post_meta to access _wpcf_belongs_parentslug_id. Then you can get the custom field value using get_post_meta, the parent ID, and the custom field slug:
...
// get the parent ID from the child postmeta
$parent_id = get_post_meta($post_id, '_wpcf_belongs_parentslug_id', true);
// get the title from the parent postmeta
$custom_title = get_post_meta( $parent_id, 'wpcf-custom-field', true );
...
Relevant Documentation: https://developer.wordpress.org/reference/functions/get_post_meta/
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
|
|
2 |
5 |
7 years, 3 months ago
julieP
|
|
Get new and previous value before save data
Started by: marcoR-6
in: Toolset Professional Support
Quick solution available
Problem:
Update the same Custom Field for All posts of a Custom post type with a certain value, when one cred edit post form is submitted from front-end.
Solution:
Please add this code in your theme’s or child theme’s functions.php file. Here I have done it for one Custom Field as example, you can copy the code to update it and add as many fields as you like:
add_action('cred_before_save_data', 'my_before_save_data_action',10,1);
function my_before_save_data_action($form_data)
{
// if a specific form
if ($form_data['id']==3780)
{
if (isset($_POST['_cred_cred_prefix_post_id']))
{
$current_post_id = $_POST['_cred_cred_prefix_post_id']; // post id
$field_old_value = get_post_meta( $current_post_id, 'wpcf-resolved-by', true ); // 'wpcf-resolved-by' Custom Field Slug
$field_new_value = $_POST['wpcf-resolved-by']; // 'wpcf-resolved-by' Custom Field Slug
echo 'Old Value '.$field_old_value ."<br>";
echo 'New Value '.$field_new_value ."<br>";
$args = array(
'post_type' => 'student', // CPT slug
'posts_per_page' => -1, // All Posts
);
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
if( get_the_ID() == $current_post_id ) // Ignore Current Edit post
continue;
$key_1_value = update_post_meta( get_the_ID(), 'wpcf-resolved-by', $field_new_value ); // // 'wpcf-resolved-by' Custom Field Slug
endwhile;
endif;
// Reset Post Data
wp_reset_postdata();
} }}
==> Please note the comments in the above code and replace your CRED form ID, Custom field slug, CPT slug, etc where needed.
Relevant Documentation:
API Doc: https://toolset.com/documentation/programmer-reference/cred-api/#cred_before_save_data
|
|
2 |
3 |
7 years, 3 months ago
marcoR-6
|
|
Is there some javascript hooks or events from cred ajax forms?
Started by: Guilherme Sampaio
in: Toolset Professional Support
Quick solution available
|
|
2 |
3 |
7 years, 3 months ago
Guilherme Sampaio
|
|
Logical problem
Started by: filipV-3
in: Toolset Professional Support
Quick solution available
Problem:
Make custom post fields required ONLY for the frontend User CRED Form when submitting or editing post from frontend.
Solution:
1. Uncheck the required field option from the back-end (if its selected).
2. Please add this code in your theme’s or child theme’s functions.php file. Please note the comments in this code and replace your field-names (slugs), form ID, etc where needed, otherwise code will not work:
add_filter('cred_form_validate','form_field_validation', 2, 10);
function form_field_validation( $field_data, $form_data ) {
// field data are field values and errors
list($fields,$errors)=$field_data;
// validate if specific CRED form ID
if ( $form_data['id'] == 3650 ) {
// set error message per field
if ( $fields['wpcf-text-field']['value'] == '' ) // Field slug with wpcf "wpcf-text-field"
$errors['text-field'] = 'Text Field must not be empty'; // Field slug without wpcf "text-field"
if ( $fields['wpcf-text-field2']['value'] == '' )
$errors['text-field2'] = 'Text Field 2 must not be empty';
}
return array( $fields, $errors );
}
Related ticket: https://toolset.com/forums/topic/required-fields-not-working-in-cred/#post-304667
|
|
2 |
6 |
7 years, 3 months ago
Noman
|
|
Save a record to a category based on the field select
Started by: Alex Alex
in: Types Community Support
|
|
2 |
2 |
7 years, 3 months ago
Luo Yang
|
|
CRED API Headers in notifications sent only if from is set
Started by: romanB-3
in: Toolset Professional Support
|
|
3 |
15 |
7 years, 3 months ago
Luo Yang
|
|
Error in documentation about cred notification numbers
Started by: romanB-3
in: Toolset Professional Support
|
|
2 |
3 |
7 years, 3 months ago
romanB-3
|
|
Conditional cred notifications
Started by: romanB-3
in: Toolset Professional Support
Quick solution available
|
|
3 |
13 |
7 years, 3 months ago
romanB-3
|
|
Hook
Started by: Franck
in: Toolset Professional Support
|
|
2 |
2 |
7 years, 3 months ago
Noman
|
|
How to use cred api
Started by: Roberto Spagnuolo
in: Toolset Professional Support
|
|
3 |
9 |
7 years, 3 months ago
Shane
|
|
Error while submitting a form
Started by: romanB-3
in: Toolset Professional Support
|
|
2 |
5 |
7 years, 3 months ago
romanB-3
|
|
Test if post has parent post of specific custom post type
Started by: romanB-3
in: Toolset Professional Support
|
|
2 |
4 |
7 years, 3 months ago
romanB-3
|