So far I have been able to locate the form user_profile_form by using

function mytheme_form_alter(&$form, &$form_state, $form_id) {
  $print = '<pre>' . print_r($form, TRUE) . '</pre>';
  if (module_exists('devel')) {
    dsm($form_id); // print form ID to messages
  }
  else {
    drupal_set_message($form_id); // print form ID to messages
  }
  if (module_exists('devel')) {
    dsm($form); // pretty print array using Krumo to messages
  }
  else {
    drupal_set_message($print);  // print array to messages
  }
}

from the comments on http://api.drupal.org/api/drupal/modules%21system%21system.api.php/funct...

and using

function mytheme_form_user_profile_form_alter(&$form, &$form_state, $form_id){
  //unset($form['picture']);
  $form['picture']['picture_delete']['#description'] = 'Hello World' ;
  $form['picture']['picture_profile_invisible'] = array(
    '#type' => 'checkbox',
    '#title' => t('Invisible picture'),
    '#access' => !empty($account->picture->fid),
    '#description' => t('Check this box to make picture invisible.'),
  );

  return;
}

in my template.php, I've been able to change the text from the normal description Check this box to delete your current picture. to Hello World but I would expect that the line below starting $form['picture']['picture_profile_invisible'] would add another checkbox. Instead nothing else is added to the rendering of the page and for the life of me I cannot find out how the page is rendered. I have created a page--edit--user.tpl.php which just came up blank (after a cache clear it gave me all the bootstrapped Drupal items, javascript etc.., but was blank html with no indication of what to try and render)

What I wish to do is add another checkbox so that on the user profile page the picture is invisible but is visible as avatars on created articles etc... which I know is going to mean further storage down the line for form processing once the checkbox is in place, but I cannot follow the path in D7 as to how authenticated user's pages are rendered and processed.

Thank you in advance.

Comments

gints.erglis’s picture

You must place this function in custom module. In template.php file you can alter #values, but can't add renderable array. And from other side, that functionality should be independent of the themes.

Anonymous’s picture

that's a good starting point, would I have to duplicate and enable th "user" module under some other name, or is there a way of subtheminng for moudles ?

gints.erglis’s picture

Create your first simple Drupal 7 module
http://reinholdweber.com/2010/06/28/create-your-first-simple-drupal-7-mo...

Follow these simple steps in example.
NB! Do not name the custom module the same as the theme!

Anonymous’s picture

Atrocious spelling in my last post, and thank you for the link, the problem I have here is that I am going to need to override the user module where everything internally points to that, so to maintain the same links to user/*/edit I'm going to be working on a template templates/page--user--edit.tpl.php which would be default refer back to the original user module.

So unless someone knows different there is no real way to "override" a core module, instead one is stuck with modifying it. But how about this, setting up a new field and widget within the administration and the hiding the default logo image. But then how would one go about starting to build a module for a new field ?

gints.erglis’s picture

One solution to hide user picture from the user profile page.
In the mytheme/template.php

<?php
function mytheme_preprocess_user_profile(&$variables) {
  unset($variables['user_profile']['user_picture']);
}
?>

Let's add checkbox! Go to admin/config/people/accounts/fields and add checkbox field.
Now improve function.

<?php
function mytheme_preprocess_user_profile(&$variables) {
    if($variables['field_mycheckbox'][0]['value'] == 1){
      unset($variables['user_profile']['user_picture']);
    }
}
?>
Anonymous’s picture

Thank you, that's the kind of simplicity I'll strive for.

Anonymous’s picture

It turned out to be a little more complex. But here's the solution.

added to template.php

// removes image on view user pages but keeps Avatar image in comments and ...submitted by XXX
function mytheme_preprocess_user_profile(&$variables) {
    if( is_array($variables['elements']['#account']->field_mycheckbox) &&  $variables['elements']['#account']->field_mycheckbox['und'][0]['value'] == 1){
      unset($variables['user_profile']['user_picture']);
    }
}

adding a field in /admin/config/people/accounts/fields add Field Type Boolean and Widget single on/off checkbox in this example is called field_mycheckbox for the machine name, and after creation I chose to tick the box "Use field label instead of the "On value" as label" Labelling the field as "Hide Avatar Image on view user page."

The is_array seemed necessary for existing accounts on the website until they had been edited, it was triggering errors in the dblog. Caches needed to be cleared.

dianacastillo’s picture

I have tried adding this : function mytheme_preprocess_user_profile(&$variables)
as described above in order to modify my user edit page, but it seems to never get there.
Does anyone have another idea?

Diana Castillo