function filter_default_format
Same name in other branches
- 9 core/modules/filter/filter.module \filter_default_format()
- 8.9.x core/modules/filter/filter.module \filter_default_format()
- 10 core/modules/filter/filter.module \filter_default_format()
- 11.x core/modules/filter/filter.module \filter_default_format()
Returns the ID of the default text format for a particular user.
The default text format is the first available format that the user is allowed to access, when the formats are ordered by weight. It should generally be used as a default choice when presenting the user with a list of possible text formats (for example, in a node creation form).
Conversely, when existing content that does not have an assigned text format needs to be filtered for display, the default text format is the wrong choice, because it is not guaranteed to be consistent from user to user, and some trusted users may have an unsafe text format set by default, which should not be used on text of unknown origin. Instead, the fallback format returned by filter_fallback_format() should be used, since that is intended to be a safe, consistent format that is always available to all users.
Parameters
$account: (optional) The user account to check. Defaults to the currently logged-in user. Defaults to NULL.
Return value
The ID of the user's default text format.
See also
5 calls to filter_default_format()
- DrupalWebTestCase::drupalCreateNode in modules/
simpletest/ drupal_web_test_case.php - Creates a node based on default settings.
- FilterDefaultFormatTestCase::testDefaultTextFormats in modules/
filter/ filter.test - Tests if the default text format is accessible to users.
- filter_process_format in modules/
filter/ filter.module - Expands an element into a base element with text format selector attached.
- NodeEntityFieldQueryAlter::setUp in modules/
node/ node.test - Sets up a Drupal site for running functional and integration tests.
- profile_view_field in modules/
profile/ profile.module
6 string references to 'filter_default_format'
- block_update_7004 in modules/
block/ block.install - Add new blocks to new regions, migrate custom variables to blocks.
- block_update_7005 in modules/
block/ block.install - Update the {block_custom}.format column.
- comment_update_7006 in modules/
comment/ comment.install - Migrate data from the comment field to field storage.
- filter_update_7005 in modules/
filter/ filter.install - Integrate text formats with the user permissions system.
- node_update_7006 in modules/
node/ node.install - Convert body and teaser from node properties to fields, and migrate status/comment/promote and sticky columns to the {node_revision} table.
File
-
modules/
filter/ filter.module, line 531
Code
function filter_default_format($account = NULL) {
global $user;
if (!isset($account)) {
$account = $user;
}
// Get a list of formats for this user, ordered by weight. The first one
// available is the user's default format.
$formats = filter_formats($account);
$format = reset($formats);
return $format->format;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.