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 - 6,286 through 6,300 (of 6,310 total)
Then change the JavaScript code to accept an empty string value instead of defaulting to zero:
$('.aux_anmelder_id', list).each(function(index, element) {
var id = $(element).text();
$('option[value="' + id + '"]', select).appendTo(new_select);
});
This should copy the unset value from the original select field into the cloned select field. Change the select_text attribute here from "bitte auswählen" to "wer wird angemeldet"
Problem: I understand that a CRED form can be used to create posts. I understand that a different CRED form can be used to edit a post. Can you explain how to set up a CRED form to edit a post that does not exist yet?
Also, how can I restrict the number of posts a User can create with CRED?
Solution: CRED forms are not restricted to a particular post, so you can reuse the same CRED form for any post in a particular post type.
To limit the number of posts a User can create with CRED, you can use a View. Let's say you have a custom page with a CRED form that allows your Users to create an Ad. That Ad's author will be the current User, once it's created. You need to determine whether or not to display the CRED form, based on how many Ads have been created by the current User. You can filter a View by post author, and you can react differently based on the number of results.
Set up a View that shows all posts where the author is equal to the current User. A View's Loop Output contains two sections - results found and no results found. You can use these two sections to display different information based on whether or not there is already a post by the current User. Or, you can use other conditional code that tests the number of results found.
Problem: I would like to use a PHP variable in a shortcode attribute.
Solution: You can't use PHP variables directly in your shortcode attributes. Instead, you could create a custom shortcode that returns the value of that variable, and place that shortcode instead of the variable in your attribute.
$working_memap_id = 'some-post-slug';
add_shortcode( 'global_memap_id', 'global_memap_id_func');
function global_memap_id_func($atts)
{
global $working_memap_id;
return $working_memap_id;
}
[cred form form="properformname" post="[global_memap_id]"]
Register the name of the shortcode in Toolset > Settings > Frontend content > 3rd party shortcode arguments.
Problem: I have a CRED email notification set up that is sent out, but the message is incomplete. Some of the text that should be displayed in the middle of the notification does not appear, but other content beneath it does appear.
Solution: Ensure the syntax used to display your content is exactly right. An unterminated types field like this will cause a gap in your message, or a truncated message, depending on the content displayed after the field:
Problem: I have a CRED form that creates child posts. I would like to have the parent post be automatically assigned as the current post where the CRED form is displayed. I would also like a custom field value to be automatically the current User's name.
Solution:
There are two ways you can predefine a CRED form field value. You can use the "value" attribute, or you can use the "urlparam" attribute. The value attribute allows you to pass a value in using another shortcode, and the urlparam attribute allows you to capture a URL parameter variable and use that as the value.
You can use the wpv-user shortcode and the value attribute to predefine the user's name:
If you want to use the current post ID as the value of the parent field, you can use the wpv-post-id shortcode and the $current_page operator:
[cred_field field='_wpcf_belongs_parentslug_id' value='[wpv-post-id id='$current_page']' select_text='--- not set ---' class='form-control' output='bootstrap']
Pro tip: if you want to hide the predefined parent select field you can wrap it in a hidden div:
<div style="display:none;">
[cred_field field='_wpcf_belongs_parentslug_id' value='[wpv-post-id id='$current_page']' select_text='--- not set ---' class='form-control' output='bootstrap']
</div>