Using profile module, I have set up a number of fields for users address details. Eg. House no., Address line 1, Address line 2 and so on. They are all private, and so each displays "The content of this field is kept private and will not be shown publicly." underneath.

This looks a bit ridiculous from a design point of view. I would like to remove all these notices and replace them with one right at the top which says "The content of this SECTION is kept private and will not be shown publicly." This makes more sense, right?

Can anyone help out? I have already got a user_register.tpl.php but all it does is print_r(drupal_render($form) - I need to find out how to customize the form itself.

Thanks

Comments

radsail’s picture

Already a solution? I've the same problem with making a Terms of Agreement.

mrmelson’s picture

OK...I am sure the hardcore drupalers could have done this better ... but here is an easy fix I just implemented for this.

Step 1: Intercept the user-registration form & pass it to a template by adding the following to template.php:

/* Register some theme functions for forms, theme functions
* that have not been registered by the module that created
* them...
*/
function YOURTHEMENAMEHERE_theme() {
  return array(
    'user_register' => array(
      'arguments' => array('form' => NULL),
      'template' => 'user-register',
    ),
  );
}

function YOURTHEMENAMEHERE_preprocess_user_register(&$vars) {
  $vars['form_markup'] = drupal_render($vars['form']);
}

Step 2: Create a user-register.tpl.php file with the following that strips the unwanted text:

 print str_replace("The content of this field is kept private and will not be shown publicly.", "", $form_markup); 
stevekerouac’s picture

I followed instructions here to add a template.php function yourtheme_theme (note - you can add lines to this function if it already exists) and function yourtheme_preprocess_user_register and then I put the following in user-register.tpl.php

<?php
$stripped = str_replace("The content of this field is kept private and will not be shown publicly.", "", $rendered);
print $stripped;
?>
Anonymous’s picture

Just search for this string in the translations page. You can replace the string with a blank space to override it.

Look ma' ... no code!

zinasahib’s picture

Hello!
I ran into this problem today, and unfortunately, none of your suggestions work (I am simply running the chameleon theme which does not have its own template.php file to begin with), and the line doesn't exist in any of my translation files!!
After spending 2.5 hours, I finally found an easy solution, which is stated below.
A quick note before I head into my solution: the reason this "stupid" line keeps appearing for every profile field I define is that I select:

Visibility: Private field, content only available to privileged users.

which is exactly what I need for my community. As I don't want to share users' details publicly. If I select the other option (there is a total of 4 options): Public field, content shown on profile page and on member list pages. - that line won't show up, but its not what I want functionality wise.

Here is my simple solution:

Go to:

htdocs>modules>profile>profile.module

scroll down to (approximately line #341): where you see:

if ($field->visibility == PROFILE_PRIVATE) {
$output .= ' '. t('The content of this field is kept private and will not be shown publicly.');
}

and simply remove the text between ' '.

I personally did not delete it -just in case I might need to bring it back in future, so I just cut it from the line and pasted it into a comment that I attached below.

There! Phew!

Oh - and Ryan: no code here either ;-)

daneyuleb’s picture

That most certainly is code that you're messing with, and it's core code at that. Every time Drupal is updated, that fix needs to be reapplied.

Better to use translation, or strings override, or template.php, to deal with it.

daveparrish’s picture

String Overrides module worked well for me.

jmcerda’s picture

exactly

alangbrown’s picture

That's a neat module - This worked great for me, always reluctant to start editing code.

Slightly concerned about performance if used a lot on a big site, but hopefully the caching will take care of this. Either way not an issue for the site i used it on.

Another great module showing the flexibility of Drupal.

flock’s picture

Would you mind giving some instructions?, I have the module installed, and I have fed the string [text only], and what I want to appear in stead. but it does not work, where should I be copying the content to override?, should it have some sort of code in it versus me just using the text?

These are the string I want to change to my own as they appear in the "Register" form:
"Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores."
"A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."
"The content of this field is kept private and will not be shown publicly."
"The content of this field is kept private and will not be shown publicly."
"The content of this field is kept private and will not be shown publicly."

Thanks !

Bartezz’s picture

@MrMelson

print str_replace(t('The content of this field is kept private and will not be shown publicly.'), '', $form_markup); 

For multilingual sites if I'm not mistaken

________________
Live fast die young

jdudziec’s picture

1. Create new module
2. Inside NAME.module put

function NAME_form_alter(&$form, &$form_state, $form_id) {
  switch( $form_id ) {
    //...
    case 'user_register':
      foreach($form as &$section) {
        if(is_array($section) && array_key_exists('#type', $section) && $section['#type'] == 'fieldset' ) {
          foreach($section as &$field) {
            if( is_array($field) && array_key_exists('#description', $field) ) {
              $field['#description'] = str_replace( t('The content of this field is kept private and will not be shown publicly.'), '', $field['#description']);
            }
          }
        }
      }
    break;
    //...
  }
}

It will remove unwanted string from all profile_* fields.

Cheers,
Jan