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 - 751 through 765 (of 794 total)
Problem:
A form includes several numerical fields. The total should be calculated when the form is submitted and stored in another field.
Solution:
You will need to use the Forms API hook cred_save_data and write a snippet of custom code that retrieves the field values, performs the calculation, and stores the result.
Problem:
Client is using the Forms cred_form_ajax_upload_validate hook to restrict the acceptable file types that can be uploaded for a file custom field, but it is not working, the accepted file types are being rejected.
Solution:
Their code wrongly defines the file types which do not match the file type reported by the global $_FILES object used for the test (e.g. they are testing for "application/text" instead of "text/plain".
add_filter('cred_success_redirect', 'custom_redirect_form_abc',10,3);
function custom_redirect_form_abc($url, $post_id, $form_data)
{
if ($form_data['id']==12345){
if (isset($_POST['form_submit_2'])) {
$url = "https://yoursite.com/alternate-redirect/";
}
}
return $url;
}
Note that the "form_submit_2" key may need to be modified in your site. Log or dump the $_POST superglobal to find the appropriate key when you submit using the second submit button. You must also set the Form to redirect to some existing post or page in wp-admin, or the redirect override code will not work.
Use a CRED form for creating child post, I need to get parent post information within cred_save_data action hook using PHP codes.
Solution:
In the CRED form for creating child post, there is a a parent post selector, it will pass a POST parameter "@client-client-portfolio_parent" to target page, so you will can get the parent post ID with below codes:
Problem:
The notification email for New Messages not displaying user name and messages.
Solution:
You can use Toolset forms hook 'cred_subject_notification_codes' to add custom placeholders that will hold the username and later use this custom placeholder within your notification body.
I have form that collects first name and last name for a post called "OT Profile". I want the post-tile to "FirstName LastName PostID" .... and the slug to "firstname-lastname-postID"
Can you please share the cred hook code that I would use to do this?
Solution:
If it is, it is possible with Form action hook cred_save_post, see our document: