CRED is a WordPress plugin that lets you easily build front-end forms for creating and editing content and users.
CRED User Guides include detailed documentation on creating forms, including related fields that belong to the content or the users, validating the input and displaying the forms with custom HTML styling.
When you ask for help or report issues, make sure to tell us the versions of the Toolset plugins that you have installed and activated.
Viewing 15 topics - 1,441 through 1,455 (of 1,546 total)
Problem:
The user has a form that creates a post and asks if he can implement a recurring post feature. For example, create a post for a user that has date times set for every Monday until next month
Solution:
First of all, note that a Toolset form is meant to create or edit only ONE post. To be able to create multiple posts, you will need to create custom code hooked to the cred_save_data action, that will create the additional posts. https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
To pass data from the form to your action function, you can use generic fields.
Now, it is a matter of how you intend to do it. You may want to calculate the additional posts' arrival and departure dates/times on the frontend with Javascript, and pass them to the action function.
Or you may want to pass the rule(every week until a certain date) and calculate the date on the server end inside your action function.
Problem: I am trying to use a generic field in my Form. The field has a slug of page, but when I try to submit the Form I am shown an error stating that the page does not exist.
Solution: Avoid using WordPress-reserved terms like page or post for generic field slugs. See the link below for a more comprehensive list of terms that are reserved in WordPress.
Problem: I have a Commerce Form that is used to publish a post and connect it to an Order. The Commerce Form is configured to publish the post when the Order is completed. However, sometimes clients submit the same Form multiple times for the same Order. In this case, several posts are created but only the most recent post is published when the Order is completed. I would like to publish all the posts connected to the Order when the Order is completed.
Solution: Forms Commerce is not designed to support more than one post per Order, so custom code is required to make this work. See the example here using the cred_commerce_after_order_completed API:
// publish all posts created when one commerce form is submitted mutliple times in the same order
add_action( 'cred_commerce_after_order_completed', 'publish_all_ordered_posts', 10, 1 );
function publish_all_ordered_posts( $data ) {
// which order was completed?
$order_id = $data['transaction_id'];
// which posts were created in this order?
$all_order_posts = get_post_meta( $order_id, '_cred_post_id');
// loop over all the created posts
if( !is_array( $all_order_posts ) )
return;
foreach( $all_order_posts as $all_order_post ) {
// check the post status
$this_post_status = get_post_status( $all_order_post );
// publish any unpublished posts
if ( $this_post_status != 'publish' ) {
$args = array(
'ID' => $all_order_post,
'post_status' => 'publish'
);
wp_update_post( $args );
}
}
}
Problem:
Automatically selecting the post to add a RFG to, in front-end form
Solution:
you can use the Toolset Form's hook "cred_save_data" and to set/connect the parent post, you can use the post-relationship API function: toolset_connect_posts()