CRED plugin provides an API, making it easy to customize your post or user forms. The API includes hooks (actions and filters) to accomplish specific tasks using PHP code.
When you ask for help or report issues, make sure to tell us all related information about your form and what you want to achieve.
Viewing 15 topics - 736 through 750 (of 794 total)
Problem: I have an edit post Form that includes a custom field. I would like to make the field empty when the Form loads. If the User adds a value to this field, I want to save that value as the custom field value. However, if the User does not add a value to this field I want to keep the original field value.
Solution:
It depends on the type of field and settings. In some simple cases, you can edit the Form code and add the value attribute to the field shortcode. Set the value to be an empty space, like this:
However, if it's a numeric field this will show a validation error if the User does not modify the value on the front-end, because an empty space is not a number. That can be confusing, and there are some other quirks so the most foolproof way to set this up is to delete the actual field from the Form. Add a generic field to capture a new value, then use the Forms API to overwrite the existing field value with the new field value. Here is an example:
// overwrite the values of submitter custom fields if the User supplies them in the generic fields of Form 8167
add_action('cred_save_data', 'overwrite_submitter_fields_action',10,2);
function overwrite_submitter_fields_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==8167)
{
if( isset($_POST['offer_email']) && trim($_POST['offer_email']) != '' )
{
update_post_meta( $post_id, 'wpcf-submitter_email', $_POST['offer_email'] );
}
if( isset($_POST['offer_title']) && trim($_POST['offer_title']) != '' )
{
update_post_meta( $post_id, 'wpcf-submitter_title', $_POST['offer_title'] );
}
}
}
I get this message often in the console log.
[Intervention] Slow network is detected
Solution:
It is a "Web Open Font Format" static file, it is only 7k file size, it should not conduct slower response problem, I suggest you check your server config settings, make sure your webserver is capable to response lots of requests fastly in the same time, for example:
I have an existing timestamp for when the CPT member-profile is updated by Admin. That works fine. Now I want a separate timestamp to keep track of when the member updates his own profile from the front end via CRED form. I got that to work using cred_save_data hook. The problem is, my backend hook is using save_post hook, so when member saves his profile on the front end, it updates both fields.
Is there a way I can check this from the save_post hook?
Solution:
There is a hidden field "_cred_cred_prefix_form_id" in Toolset post form, it stores value of current Toolset form ID, you can use it to check if it is submitted by Toolset post form insider in the "save_post" action hook, for example, change this line of your PHP codes from: