Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-12205

Custom Profile Field display bug

    Details

      Description

      I have set up a (numerical) Custom Profile Field, which is an optional field for the user. If the user does not fill the field in, I hoped it wouldn't display on the topic pages. I posed the question on the BB3 support forums, and have been advised that it is a bug and that I should report it here, so...
      The custom field has the following settings:

      Load Settings, 'Display custom profile fields on topic pages:' = set to "Yes"
      Custom Profile Fields, 'Show field if no value was selected:' = un-ticked (so a "no")
      The Default Value field is blank.
      The field is blank within the UCP (where the user hasn't filled the field in).

      Despite the setting above to not show if no value is selected, it does show, with a value of '0', see screenshot attached.

      I'm using version 3.0.12, style Subsilver2

        Activity

        Hide
        nickvergessen Joas Schilling added a comment -

        Set default value to 0 instead of empty, so the default is equal to the user input and therefor hidden.

        Show
        nickvergessen Joas Schilling added a comment - Set default value to 0 instead of empty, so the default is equal to the user input and therefor hidden.
        Hide
        davethecat davethecat added a comment -

        Hi Joas,
        That's what I did to begin with, default value was '0', but the field still showed on the Topics pages when the user didn't fill the field out. So I raised it as a query on the regular phpBB forums, and was advised to leave the Default value field blank, but that has the same result, hence I was advised that it was a bug.

        I have now re-set the default value back to '0' as you suggest just to try it again, but this still results in the custom profile field showing on the topic pages for all users, regardless of whether they have filled out the field on their profile or not.

        As we are a cat-related board, the Custom field for our users is "How many cats in your household?", so if a user doesn't fill the field out at all, it shows on their posts on the topic pages as them having '0' cats, whereas it would be better if that field didn't show at all unless they actually put a value in.

        So I believe, (unless there is another setting elsewhere that I've so far missed), that this is a bug. Any further help appreciated!

        Show
        davethecat davethecat added a comment - Hi Joas, That's what I did to begin with, default value was '0', but the field still showed on the Topics pages when the user didn't fill the field out. So I raised it as a query on the regular phpBB forums, and was advised to leave the Default value field blank, but that has the same result, hence I was advised that it was a bug. I have now re-set the default value back to '0' as you suggest just to try it again, but this still results in the custom profile field showing on the topic pages for all users, regardless of whether they have filled out the field on their profile or not. As we are a cat-related board, the Custom field for our users is "How many cats in your household?", so if a user doesn't fill the field out at all, it shows on their posts on the topic pages as them having '0' cats, whereas it would be better if that field didn't show at all unless they actually put a value in. So I believe, (unless there is another setting elsewhere that I've so far missed), that this is a bug. Any further help appreciated!
        Hide
        nickvergessen Joas Schilling added a comment -

        Okay, after looking at the code the "hide if no value is selected" seems to be broken for integers.

        Temporary fix for your site:
        includes/functions_profile_fields.php find:

        			case 'int':
        				if ($value === '' && !$ident_ary['data']['field_show_novalue'])
        				{
        					return NULL;
        				}
        				return (int) $value;
        			break;

        replace with:

        			case 'int':
        				if (!$value && ($value === '' || $value === null) && !$ident_ary['data']['field_show_novalue'])
        				{
        					return NULL;
        				}
        				return (int) $value;
        			break;

        Show
        nickvergessen Joas Schilling added a comment - Okay, after looking at the code the "hide if no value is selected" seems to be broken for integers. Temporary fix for your site: includes/functions_profile_fields.php find: case 'int': if ($value === '' && !$ident_ary['data']['field_show_novalue']) { return NULL; } return (int) $value; break; replace with: case 'int': if (!$value && ($value === '' || $value === null) && !$ident_ary['data']['field_show_novalue']) { return NULL; } return (int) $value; break;
        Show
        nickvergessen Joas Schilling added a comment - 3.0: https://github.com/phpbb/phpbb/pull/2059 3.1: https://github.com/phpbb/phpbb/pull/2060
        Hide
        davethecat davethecat added a comment -

        Thanks Joas, that's worked perfectly!
        Your help is greatly appreciated.

        Show
        davethecat davethecat added a comment - Thanks Joas, that's worked perfectly! Your help is greatly appreciated.

          People

          • Assignee:
            nickvergessen Joas Schilling
            Reporter:
            davethecat davethecat
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development