Forms 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:
[cred_delete_post_link post="145" text="Delete this car" action="delete"]

//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). Must match the expected Field's syntax. For example, date fields require a valid timestamp instead of a date string. Does not apply to all field types, e.g. taxonomies.
  • 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. Text to be used as a placeholder (HTML5) for text fields. Defaults to none.
  • 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.
  • single_select Optional. Used by fields for Hierarchical Taxonomies (like Categories) to signify that the select field does not support multi-select mode.
  • max_width Optional. Maximum width for image fields.
  • max_height Optional. Maximum height for image fields.
  • max_results Optional. Maximum results in parent select field.
  • use_select2 Optional. Used in parent select fields. Options are always and never. It will render the parent select field as a Select2 field or not, depending on the value set.
  • order Optional. Order for parent select field (title or date). Will only work if use_select2 is set to always.
  • ordering Optional. Ordering for parent select field (i.e. "asc", "desc"). Will only work if use_select2 is set to always.
  • required Optional. Select whether parent field is required. Defaults to false
  • no_parent_text Optional. Text for no parent selection in parent field.
  • select_text Optional. Text for required parent selection.
  • validate_text Optional. Text for the error message displayed when parent is not selected.
  • author Optional. Use it with a parent selector field to specify that the list of parent posts should be limited to those authored by the mentioned user ID. The value $current can be used to define that the current user should only see their own parent posts in a dropdown.
Output

More Usage examples

Example
//Render the Mobile Types field defined for Agent post type
[cred_field field="mobile" post="agent" value="555-1234"]
// List parent posts limited to those authored by the current user.
[cred_field field='@relationship-slug.parent' select_text='--- not set ---' class='form-control' output='bootstrap' author="$current"]

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”)
[cred_form form="Edit Car" post="145"]

//Display form to create a car post (use form with title “Create Car”)
[cred_form form="Create Car"]

//Display form with ID 120
[cred_form form="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, checkboxes, date, hidden, radio, select, multiselect, file, image, email, numeric, integer, embed, url, skype, phone, password, textfield, textarea, wysiwyg, audio, video, colorpicker).

  • 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
// basic generic email field
[cred_generic_field field="gmail" type="email" class=""]
 {
  "required":0,
  "validate_format":0,
  "default":""
 }
[/cred_generic_field]


// generic user id field for automatic email notifications
[cred_generic_field field="wpcf-user" type="select" class="" urlparam=""]
 {
  "generic_type" : "user_id",
  "required" : 1,
  "validate_format" : 0,
  "persist" : 1,
  "default" : 12,
  "options" : [
    {"value":"user1","label":"User1"},
    {"value":"user2","label":"User2"},
    {"value":"user3","label":"User3"}
  ]
 }
[/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”)
[cred_user_form form="Edit User" user="23"]

//Display form for editing current logged in user (use form with title “Edit User”)
[cred_user_form form="Edit User"]

//Display form to create a user (use form with title “Create User”)
[cred_user_form form="Create User"]

//Display form with ID 50
[cred_user_form form="50"]

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

toolset-edit-post-link

Description

Outputs the link to a Toolset Form for editing a post.

This shortcode needs to be self-closed with the anchor (link) text in the middle. The anchor text can use the %%POST_TITLE%% and %%POST_ID%% placeholders to dynamically display the post’s title and ID.

Arguments
  • content_template_slug. Holds the slug value of the Content Template that will be used to render the page when clicking the edit link. Please note that either the content_template_slug or the layout_slug attribute need to be set for the edit link shortcodes to work.

  • layout_slug. Holds the slug value of the layout that will be used to render the page when clicking the edit link. Please note that either the content_template_slug or the layout_slug attribute need to be set for the edit link shortcodes to work.

  • style (opt). Optional. The style of the element. Takes a string value and will be added unchanged to the HTML element

  • target. Optional. Defines the window in which the link will be opened. This can be the current window (self), top window (top), or a new window (blank). Defaults to self.

  • class. Optional. The class of the element. Takes a string value and will be added unchanged to the HTML element

Output

More Usage examples

Example
[toolset-edit-post-link content_template_slug="template-for-editing-posts"]Edit %%POST_TITLE%% with a Toolset Form[/toolset-edit-post-link]