回答:
ブロックまたはブロックを追加するカスタムモジュールで、次のコードを追加します。
if (user_is_logged_in() == TRUE) {
    global $user;
    print "Welcome " . $user->name;
}
else {
    print "Please log in.";
}これは、CURRENTユーザー情報が必要な場合に便利です。おそらくこれもuser_is_logged_in機能のために。
モジュールでこれを行いたい場合(ブロックにphpコードを追加するのではなく、バージョン管理下にないことをお勧めします)、これを行うことができます:
(この場合、このコードはすべてuserwelcomeという名前のカスタムモジュールに入れられます。)
/**
 * @file
 * Adds a block that welcomes users when they log in.
 */
/**
 * Implements hook_theme().
 */
function userwelcome_theme($existing, $type, $theme, $path) {
  return array(
    'userwelcome_welcome_block' => array(
      'variables' => array('user' => NULL),
    ),
  );
}
/**
 * Implements hook_block_info().
 */
function userwelcome_block_info() {
  // This example comes from node.module.
  $blocks['welcome'] = array(
    'info' => t('User welcome'),
    'cache' => DRUPAL_CACHE_PER_USER,
  );
  return $blocks;
}
/**
 * Implements hook_block_view().
 */
function userwelcome_block_view($delta = '') {
  global $user;
  $block = array();
  switch ($delta) {
    case 'welcome':
      // Don't show for anonymous users.
      if ($user->uid) {
        $block['subject'] = '';
        $block['content'] = array(
          '#theme' => 'userwelcome_welcome_block',
          '#user' => $user,
        );
      }
      break;
  }
  return $block;
}
/**
 * Theme the user welcome block for a given user.
 */
function theme_userwelcome_welcome_block($variables) {
  $user = $variables['user'];
  $output = t('Welcome !username', array('!username' => theme('username', array('account' => $user))));
  return $output;
}次に、テーマでこのブロックのテーマ設定をオーバーライドしたい場合は、これを行います(テーマのtemplate.phpファイルで):
/**
 * Theme the userwelcome block.
 */
function THEMENAME_userwelcome_welcome_block(&$variables) {
  // Return the output of the block here.
}これはカスタムモジュールであるため、モジュール内のテーマ関数を直接更新することもできます。
カスタムモジュールを使用したくない場合は、PHPコードでカスタムブロックを作成し、これを追加できます。
global $user;
// Only for logged in users.
if ($user->uid) {
  print 'Welcome ' . theme('username', array('account' => $user));
}theme_userwelcome、機能するはずtheme_userwelcome_welcome_blockで置くことがテーマではないuserwelcomeモジュール。おそらく、userwelcome_themefunctionは実際に呼び出されuserwelcome_theme_theme(テーマの名前が2つのテーマワードに置き換えられるhook)、テーマに配置される必要がありtheme_userwelcomeます。機能しuserwelcome_block_view、にuserwelcome_block_info残りuserwelcomeます。
                    ビューモジュールを使用します。新しいビューの作成>ユーザーの表示>表示のブロック。コンテキストフィルターを追加>デフォルト引数を提供>ログインユーザーのユーザーID。任意のテキスト/トークンまたはユーザープロファイルフィールドを含めるようにフィールドを構成します(結果を書き換えることができます)。ブロックを保存して地域に追加します。
1つのモジュールで完了し、コードはありません。
-lunk_rat