Advertisement:

Author Topic: hide custom field to registered users  (Read 1469 times)

Gabender

  • Jr. Member
  • **
  • Posts: 53
hide custom field to registered users
« on: January 19, 2014, 11:54:02 pm »
 :) hello guys, I created a custom field that requires the telephone number of the user. How can I hide this field for all registered users?

::::::::::::::

Unfortunately, registered users have their own profile that already includes the phone number, so when they publish an ad the phone number is displayed twice if they fill out the custom field.
« Last Edit: January 19, 2014, 11:56:45 pm by Gabender »

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: hide custom field to registered users
« Reply #1 on: January 20, 2014, 12:42:19 am »
@Gabender
Problem is that Phone number field when posting new lisiting is item related, but user's one is user related.
Unfortunately you cannot catch 1 custom field (or I do not know about it), but if you would replace i.e. city area field and use it as phone number, you could fill it with user phone.

Alternatively you can use php and javascript. Something like this:
- if user is not logged, do nothing
- if user is logged, run javascript that: hide custom field, add value to custom field

If you can check if this field has unique ID or class, it would be easy to do  ;)

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: hide custom field to registered users
« Reply #2 on: January 20, 2014, 02:32:51 am »
Hi,

I did a quick look at the helpers because I was pretty sure I had seen something regarding the custom/extra fields related to items like a possible phonenr.

In hItems.php look for this:
Code: [Select]
/***************
     * META FIELDS *
     ***************/

The functions underneith give you the manipulation of the custom fields:
http://doc.osclass.org/HItems.php#Helpers_for_meta_fields

But what should be done in my opinion is add the phonenr. to the core regarding unregistered users posting an add as part of the minimum nr. of ways to get in contact with a seller.

For now you could try the suggestions Frosti made and maybe make use of the helper functions I mentioned so you can handle it in the theme code using the extra/custom field you created.

Regards,
Eric

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: hide custom field to registered users
« Reply #3 on: January 20, 2014, 10:40:24 am »
@SmaRTeY
Yep, phone number is missing, I would suggest same process as with email:
- unregistered user needs to post email, but may to post phone
- if unregistered user is registered, all existing ads with this email are attached to him (my fix of osclass  :D) and last used non-empty phone number is taken as his own

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: hide custom field to registered users
« Reply #4 on: January 20, 2014, 10:51:38 am »
Yes, that's what I'd like be improved in core and not plugin or custom hack :)

Gabender

  • Jr. Member
  • **
  • Posts: 53
Re: hide custom field to registered users
« Reply #5 on: January 20, 2014, 06:22:39 pm »
Yes, that's what I'd like be improved in core and not plugin or custom hack :)

unfortunately all the custom fields have the same class "meta" and are not marked, so I do not think it is possible to use javascript on single DIV .. what would be the most immediate task according to you?  :'(

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: hide custom field to registered users
« Reply #6 on: January 20, 2014, 08:00:06 pm »
@Gabender
Nope, not possible  :o

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: hide custom field to registered users
« Reply #7 on: January 21, 2014, 05:07:43 pm »
I think you could use the code to check if item custom field name = "phonenr" then skip that field.
But first check on logged-in user which is an easy exisiting function returning true or false.

The custom fields are placed in item.php because of a loop of custom fields if item is in category where custom fields should be displayed.