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 - 886 through 900 (of 1,234 total)
Problem:
I have a plugin that provides Custom user and post Fields.
I want to edit them with CRED since that allows me to bring those fields to the front end in my forms.
How?
Solution:
With CRED you can control Other Plugin's fields if you want to add or edit the values of those Fields using CRED.
Follow the DOC linked below to see how.
Note!
"Complex fields" (Like Galleries, Checkboxes or similar) cannot be controlled very well with Toolset, due to the nature of those fields.
The issue here is that the user wanted to know if they could setup a crowdfunding goal with just the use of the toolset plugins only.
Solution:
This would be possible to achieve with toolset but would require some amount of work and custom coding to setup.
There are plugins out there that are dedicated for this and I was able to find one with a quick search
@https://wordpress.org/plugins/wp-crowdfunding/#description
This might be better suited for your proposed project that just using toolset alone.
Problem: I have a CRED form where Users can supply the URL of a YouTube video. I would like to store the video ID in a custom field so I can use it later in a shortcode.
Solution:
Use the following cred_save_data function to parse the URL and determine the YT video ID, then save that value into a custom field on the post.
add_action('cred_save_data', 'cred_format_youtube_video_id',10,2);
function cred_format_youtube_video_id($post_id, $form_data)
{
// if a specific form
$forms = array(12,9876);
if (in_array($form_data['id'], $forms))
{
if (isset($_POST['my_custom_video_field']))
{
$link = $_POST['my_custom_video_field'];
$video_id = explode("?v=", $link); // http://www.youtube.com/watch?v=...
if (empty($video_id[1])) {
$video_id = explode("/v/", $link); // http://www.youtube.com/watch/v/..
}
if (empty($video_id[1])) {
$video_id = explode("/youtu.be/", $link); // https://youtu.be/...
}
$video_id = explode("&", $video_id[1]); // Deleting any other params
$video_id = $video_id[0]; // here is your required video ID
// update post meta with video ID
update_post_meta($post_id, '__my_custom_video_field', $video_id);
}
}
}
Change 12,9876 to be a comma-separated list of all the forms where this custom functionality should be applied.
I am trying to: update cred to 1.9.4, I expected to see: the calculation and chart display correctly as before CRED update to version1.9.4
nnstead, I got: the calculation that worked perfectly before updating cred, (ung the cred_save_data api) ow cause the calculation to malfunction.
I have tested this in the following manner.
1. created a stagin enviroment - a copy of production
2. tested all callculation working ok on the frot end i.e. all custom functions are claculatiing and providing correct results
3. update #1 - ews plagin to 2.5.2
4. again. tested all callculation working ok on the frot end i.e. all functionalty is intact - rsults are working properly
5. update #2 - ed plagin to 1.9.4
6. again. tested all callculation working ok on the frot end - this time the claculation got broken and the rsults are not working correctly
Solution:
Here are what I found, the problem is in your custom PHP codes, plugin file functions.php, line 639!797:
// calculate education need
function calculate_education($post_ID)
{
...
}
It triggers the PHP warning message, for example:
Warning: number_format() expects parameter 1 to be float, string given in \wp-content\plugins\functions.php on line 1451
Warning: number_format() expects parameter 1 to be float, string given in \equi\wp-content\plugins\functions.php on line 1451
It is an error of your custom PHP codes, you will need to change line 650, from:
$parent_assump_post_id = wpcf_pr_post_get_belongs(get_the_ID(), 'assumption');
To:
$parent_assump_post_id = wpcf_pr_post_get_belongs($post_ID, 'assumption');
and test again
Problem: I would like to use a CRED form to save the current page URL into a custom field on a new post. I plan to use this as a "saved search" so Users can visit the same search again later.
Solution: If your form does not use AJAX, you can use the following code to automatically save the current page URL in a CRED custom field:
add_action('cred_save_data', 'save_page_url_to_custom_field',10,2);
function save_page_url_to_custom_field($post_id, $form_data) {
if ($form_data['id'] == 123)
{
update_post_meta($post_id, 'wpcf-search-url', $_SERVER['HTTP_REFERER']);
}
}
Replace '123' with the numeric ID of this CRED form, and replace "search-url" with the slug of your custom field.