filter_default_format

Versions
7
filter_default_format($account = NULL)

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.

See also

filter_fallback_format()

Parameters

$account (optional) The user account to check. Defaults to the currently logged-in user.

Return value

The ID of the user's default text format.

▾ 8 functions call filter_default_format()

block_block_configure in modules/block/block.module
Implement hook_block_configure().
block_custom_block_form in modules/block/block.module
Define the custom block form.
comment_form in modules/comment/comment.module
Generate the basic commenting form, for appending to a node or display on a separate page.
filter_form in modules/filter/filter.module
Generates a selector for choosing a format in a form.
profile_view_field in modules/profile/profile.module
taxonomy_form_term in modules/taxonomy/taxonomy.admin.inc
Form function for the term edit form.
text_field_widget in modules/field/modules/text/text.module
Implement hook_field_widget().
text_field_widget_formatted_text_value in modules/field/modules/text/text.module
Form element #value_callback to re-assign text format value for a formatted text widget.

Code

modules/filter/filter.module, line 430

<?php
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.
  $format = array_shift(filter_formats($account));
  return $format->format;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.