CRED Shortcodes

Besides the shortcodes of the list, there are special shortcodes that control the basic functionality of every form:

  • [credform][/credform]: renders a post form
  • [creduserform][/creduserform]: renders a user form
  • [cred_field field='form_messages']: renders the message containers
  • [cred_field field='form_submit' value='Submit']: renders the submit button

Warning: removing the mandatory shortcodes from your forms will cause them to break.

cred_delete_post_link

Description
Displays a link to delete a post
Arguments
  • post. Optional. The ID of post to delete. If skipped, the ID of the current post in the loop will be used.
  • text. Optional. The text to use for link (can use placeholders like %TITLE% and %ID%)
  • action. Optional. Whether to trash or permanently delete. Can take values: trash and delete.
  • class. Optional. CSS class to apply to the link.
  • style. Optional. CSS style to apply to the link.
  • message. Optional. The confirmation message before deleting the post.
  • message_after. Optional. The confirmation message after deleting the post.
  • message_show. Optional. Whether or not to show confirmation message before deleted. Can take values: 1 or 0.
  • redirect. Optional. A post ID to redirect the user after deleting the post. If set to 0, then the user will not being redirected.
Output

More Usage examples

Example
//Display link for deleting car custom post with ID 145:

//The function can also be used in PHP:
//Note that you have to echo this function in order to work properly.
The order of arguments in the function is important and should be as following:
cred_delete_post_link($post_id, $text, $action, $class, $style, $message, $message_after, $message_show, $redirect);
//Fully working example of the function:
echo cred_delete_post_link(get_the_ID(), 'Delete this post', 'delete', 'cred-refresh-after-delete my-custom-css-class', 'display: block;', 'Do you really want to delete this post?', 'Post Deleted.', 1, 1);
//Change the URL that users will be redirected to after deleting a form.
add_filter("cred_redirect_after_delete_action", "test");
function test($redurl, $post_id) {
    return "/client/";
}

cred_field

Description
Render a form field (using fields defined in Toolset Types plugin and / or Taxonomies).
Arguments
  • field. The field slug.
  • post. Optional. The Post Type where this field is defined.
  • value. Optional. Preset value (translated automatically if WPML translation exists).
  • taxonomy. Optional. Used by taxonomy auxiliary fields (eg. “show_popular”) to signify to which taxonomy this field belongs (used with “type” option).
  • type. Optional. Used by taxonomy auxiliary fields (like show_popular) to signify which type of functionality it provides (eg. “show_popular”) (used with “taxonomy” option).
  • display. Optional. Used by fields for Hierarchical Taxonomies (like Categories) to signify the mode of display (ie. “select” or “checkbox”).
  • single_select. Optional. Boolean. If the display=select argument is set, then single_select=true will only allow a single option to be selected (by default multiple options can be selected). Defaults to false.
  • readonly. Optional. Boolean. When set to true, the field will be read only. Read-only parameter can be applied only to text controls and not to other elements, like checkboxes or buttons. Defaults to false.
  • placeholder. Optional. This value is being displayed when the field is empty.
  • urlparam. Optional. A URL parameter to set default value. For example, a URL with the additional parameter ?some_param=some_value will set the some_value value to some_param.
  • output. Optional. If set to bootstrap, the form elements will get the styling from bootstrap framework. Otherwise, raw elements output will be rendered.
  • class. Optional. CSS class to apply to the link.
Output

More Usage examples

Example
//Render the Mobile Types field defined for Agent post type
[cred_field field="mobile" post="agent" value="555-1234"]

cred_form

Description
Arguments
  • form. The form title or form ID to display.
  • name. The name of the form to display.
  • post. Optional. The post ID to edit with this form. If form is an edit form and this is skipped, the ID of the current post in the loop will be used.
Output

More Usage examples

Example
//Display form for editing car custom post with ID 145 (use form with title "Edit Car")

//Display form to create a car post (use form with title "Create Car")

//Display form with ID 120

//The corresponding PHP function can also be used:
cred_form($form_id,$post_id);

cred_generic_field

Description
Render a form generic field (general fields not associated with Toolset Types plugin). Inside shortcode body the necessary options and default values are defined as JSON string (autogenerated by GUI).
Arguments
  • field. The field name.
  • type. Type of input field (i.e. checkbox, email, select, radio, checkboxes, date, file, image).
  • class. Optional. CSS class to apply to the element.
  • urlparam. Optional. A URL parameter to set default value. For example, a URL with the additional parameter ?some_param=some_value will set the some_value value to some_param.
Output

More Usage examples

Example
[cred_generic_field field="gmail" type="email" class=""]
{
"required":0,
"validate_format":0,
"default":""
}
[/cred_generic_field]

cred_user_form

Description
Arguments
  • form. The form title or form ID to display.
  • user. Optional. The ID of the user to edit. If skipeed, the current logged in user will be used.
Output

More Usage examples

Example
//Display form for editing user with ID 23 (use form with title "Edit User")

//Display form for editing current logged in user (use form with title "Edit User")

//Display form to create a user (use form with title "Create User")

//Display form with ID 50

//The corresponding PHP function can also be used:
cred_user_form($form_id,$user_id);