Forms Shortcodes
Besides the shortcodes listed below, the following shortcodes are part of the form themselves and should not be removed:
[credform][/credform]
[creduserform][/creduserform]
[cred_field field='form_messages']
[cred_field field='form_submit' value='Submit']
Warning: removing these mandatory shortcodes from your forms will cause them to break.
Displays a link to a page to add a child post
form
. The form title or form ID to use.
parent_id
. The parent of the post. Use -1
to set the parent according to the currently displayed content.
text
. Optional. The text to use for link (can use placeholders like %TITLE%
and %ID%
)
class
. Optional. CSS class to apply to the link.
style
. Optional. CSS style to apply to the link.
target
. Optional. Option to open link in a specific target. Can take values: _blank
, _self
, _top
.
attributes
Optional. Additional HTML attributes (i.e onclick
).
More Usage examples
//Display link for adding a child in form page 404 (use form with title “Create child”) [cred_child_link_form form="404" parent_id="-1" text="Create child" target="_self"]
Displays a link to delete a post
action
. You can set 'trash' to send the post to Trash or 'delete' to completely delete a post.
post
. Optional. Post ID of the post to delete. If this argument is omitted then the current post ID will be used, for example, inside a Loop.
text
. Optional. Text to use for the link. You can use meta-variables like %TITLE% and %ID%.
class
. Optional. CSS class to apply to the link.
style
. Optional. CSS style to apply to the link.
message
. Optional. Message that confirms the delete action.
More Usage examples
Display link for deleting car custom post with ID 145.
// Display link for deleting car custom post with ID 145 [cred_delete_post_link post="145" text="Delete this car"] // You can also use the following PHP tag in templates and themes that has the same functionality as the shortcode <?php cred_delete_post_link($post_id, $text, $action, $class, $style); ?>
Render a form field (using fields defined in Toolset Types plugin and / or Taxonomies).
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”).
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. This attribute is available only for certain fields.
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.
Works only on sites not using the new post relationships (legacy code). If used with new post relationships (Types 3,0+), it breaks the "order", "ordering" and "author" attributes. It can also break background checks like what post type to display in the select field for relationships. Warning: Do not use this attribute if not explicitly required.
order
Optional. Order for parent select field (title or date).
ordering
Optional. Ordering for parent select field (i.e. "asc", "desc").
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. Can be set when inserting Parent Post Selectors in Forms Builder. You can currently tweak this option for Types Select fields only when editing forms using the Expert Mode.
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.
More Usage examples
// 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"]
Use this shortcode to insert a post form.
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.
More Usage examples
//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);
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).
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
.
More Usage examples
// 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]
Makes static texts available for translation with WPML. Forms should be sent for translation via Translation Management.
Any texts wrapped in the cred_i18n shortcode will be made available in the translation editor for translation. When the form is rendered the text will be output in the current language, if a translation is available.
Note that the cred_i18n shortcode is a self-closing shortcode. The text you want to translate should be inside the shortcode. The shortcode takes a single attribute, which is used to identify the text in the translation editor.
name
. A descriptive string that is used to identify the text in the translation editor.
The translated text, when a translation is available, otherwise the original text.
More Usage examples
[cred_i18n name="declaration"]Use of this form signifies agreement with our code of conduct[/cred_i18n]
Use it to insert a user form
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.
More Usage examples
//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);
Displays a link to delete a post
type
. Optional. Defines whether to generate an HTML link or button. Can take values: link
and button
. Defaults to link
if not set.
onsuccess
. Optional. Controls what happens after a post has been deleted. A numeric ID means that we should redirect to the post with that ID. If a value is set to self
the current page will be reloaded. Defaults to self
.
action
. Optional. Defines whether to trash or permanently delete. Can take values: trash
and delete
. Defaults to trash
if not set.
item
. Optional. Define a post ID in case you want to delete a post different from the current one. Defaults to delete the current post.
class
. Optional. CSS class to apply to the link.
style
. Optional. CSS style to apply to the link.
More Usage examples
//This shortcode willl render a button that, when clicked, will delete the current post and redirect to the post with ID 123: [cred-delete-post type="button" onsuccess="123" action="delete"]Delete this[/cred-delete-post]
This shortcode deletes the relationship between two posts.
relationship
. Mandatory. The slug of the relationship whose association you want to delete.
related_item_one
and related_item_two
. Optional. IDs of the posts whose association you want to delete, in the pointed relationship. Besides IDs, those attributes can take the same values as the item attribute for Types and Views shortcodes.
role_items
. Optional. This attribute must take the value `$fromViews` to work inside a View with a relationship filter. Can be used as an alternative to the ID pair to be used inside a View loop with a post relationship filter. One item is automatically populated with the current post in the loop, and the other with the post where the View is inserted. This is useful for listing related posts and to offer a mechanism for the removal of each association.
type
. Optional. Define if the output will be presented as a link
(default) or as a `button` .
redirect
. Optional. Define whether to perform a redirection on removal success. Redirect can go to self
in order to reload the current page, it can go to a specific URL, or it can do nothing (default).
class
. Optional. Use this attribute to add classnames to the delete handle.
style
. Optional. Use this attribute to add inline styles to the delete handle.
More Usage examples
// This shortcode will render a button to delete the relationship between the current frontend page and the item with ID 123. [cred-delete-relationship type="button" related_item_one="$current" related_item_two="123"]Delete relationship[/cred-delete-relationship]
This shortcode renders a Cancel button in a relationship form and offers a way out of creating or editing a relationship. It also allows you to specify where user is taken after cancelling the form submission and which template is used when rendering the page that is shown. Note that this shortcode only works properly on relationship forms, not on the post and user forms. It lets you skip the form and get somewhere else.
select_ct
. Optional. Sets the slug of the Content Template that will be forced upon the page where the link will redirect to. If it is not set, no Content Template will be forced.
select_page
. Optional. Sets the ID of the post or page where the link will redirect to. If it is not set, the link will reload the current page.
class
. Optional. For defining additional class names for this selector.
style
. Optional. For defining additional styles for this selector.
This shortcode renders the form submission feedback. Feedback can be a success message or one of the fail messages. Note that this shortcode works properly only on relationship forms and not on post and user forms.
This shortcode submits the form to create or edit a relationship. Note that this shortcode only works properly on relationship forms, not on the post and user forms.
type
. Optional. HTML element to show. It can take as values button
or input
. Defaults to input
if not set.
label
. Optional. Sets the submit button label. Defaults to Submit
if not set.
class
. Optional. For defining additional class names for this selector.
style
. Optional. For defining additional styles for this selector.
This shortcode will output when a post is due to expire.
item
. Optional. Define a post ID for which you want to display an expiration date. Defaults to the current post.
format
. Optional. Define the date format you want to use for the output.
More Usage examples
//Display the post exparation date [cred-post-expiration format='d/m/Y']
This shortcode is used for managing relationship fields when they are available. Have in mind that only many-to-many relationships can hold fields. This shortcode takes only one attribute
name
. Mandatory. Sets the slug of the field that this shortcode will offer.
This is a wrapper shortcode for the relationship forms that encapsulates the whole form. Output of this shortcode wraps form elements with the form
HTML tag.
This shortcode displays a selector for the posts that will be connected by the relationship that is being created or edited. Note that this selector is displayed as a select2
instance.
role
. Mandatory. Can take the values of parent
or child
, to decide what relationship side will this selector offer posts to. As the form settings store the relationship that this form will create or edit, once the role is set the selector will display the right posts for the right post type.
orderby
. Optional. Can take the values of date
, title
or ID
. ID
is the default value. It will decide the order of the posts being offered in this role selector.
order
. Optional. Can take values of ASC
and DESC
. DESC
is the default value. Defines the direction for the post oreder being offered in this role selector.
author
. Optional. Can take just one value as $current
. It is used to filter the posts offered in this role selector to ones by the current user.
class
. Optional. For defining additional class names for this selector. Note that this gets applied to the select dropdown behind the select2
instance.
style
. Optional. For defining additional styles for this selector. Note that this gets applied to the select dropdown behind the select2
instance.
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.
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
More Usage examples
[toolset-edit-post-link content_template_slug="template-for-editing-posts"]Edit %%POST_TITLE%% with a Toolset Form[/toolset-edit-post-link]
Outputs the link to a Toolset Form for editing a user.
This shortcode needs to be self-closed with the anchor (link) text in the middle. The anchor text can use the %%USER_LOGIN%% and %%USER_NICENAME%% placeholders to dynamically display the user’s login and “nicename” information.
Please note that this shortcode is only available if the CRED plugin is active.
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
More Usage examples
[toolset-edit-user-link content_template_slug="template-for-editing-users"]Edit %%USER_NICENAME%% with a CRED form[/toolset-edit-user-link]