0

Following code prints user edit form in block:

function notifikacie_custom_block_info() {
 $blocks['user_profile'] = array(
   'info' => t('User profile edit'),
   'cache' => DRUPAL_NO_CACHE,
 );

 return $blocks;
}

function notifikacie_custom_block_view($delta = '') {
  $block = array();

      global $user;
      module_load_include('inc', 'user', 'user.pages');
      $block['subject'] = t('Fill your profile');
      $block['content'] = drupal_get_form('user_profile_form', $user);

  return $block;
}

But it does not print custom fields created in admin/config/people/accounts/fields. How do I print those custom fields?

2
  • from admin/config/people/accounts/display manage your filed, make sure that your fields not hidden .
    – berramou
    Commented Jan 8, 2019 at 13:16
  • It is visible, I mean, I am trying to print edit form, not print the fields itself.
    – Lub
    Commented Jan 8, 2019 at 13:32

1 Answer 1

0

I've just run your code and it works fine. Maybe it is permission related problem.

<?php
function user_profile_block_info() {
 $blocks['user_profile'] = array(
   'info' => t('User profile edit'),
   'cache' => DRUPAL_NO_CACHE,
 );

 return $blocks;
}

function user_profile_block_view($delta = '') {
  $block = array();

      global $user;
      module_load_include('inc', 'user', 'user.pages');
      $block['subject'] = t('Fill your profile');
      $block['content'] = drupal_get_form('user_profile_form', $user);

  return $block;
}

Output/result:
Here Birth Date is custom field, created form admin/config/people/accounts/fields.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.