This topic was marked solved by its starter, on April 3rd, 2015, 09:20 PM

CerealGuy

  • Posts: 343
[Hook] Custom Fields
« on August 18th, 2014, 05:34 PM »Last edited on April 3rd, 2015, 09:21 PM
I think a hook for adding custom fields would be a good thing. Adding the field with JS is a way but not a nice one.
I would suggest something like that:

call_hook('load_custom_fields', array($memID, $area, &$context['custom_fields'])); (Profile.php)

EDIT: No more need for, we have mods.xml

Nao

  • Dadman with a boy
  • Posts: 16,079
[Hook] Re: Custom Fields
« Reply #1, on August 18th, 2014, 11:17 PM »
Anyone else?

I'm not much of a hook guy, didn't write many plugins either, so I'd rather trust people to add whatever hooks they need. If you think you have a use case, then go ahead.
BTW, hooks need to be added to ManagePlugins.php as well... I don't know why, there's certainly a good reason.

CerealGuy

  • Posts: 343
[Hook] Re: Custom Fields
« Reply #2, on August 19th, 2014, 11:52 AM »
Perhaps to check if all hooks which the plugin needs are available. InviteMod/HideMod cant get installed if the additional hooks aren't "installed". Therefore its a good thing, a missing hook can cause big troubles.
[Hook] Re: Custom Fields
« Reply #3, on October 13th, 2014, 04:05 PM »
*Bump*
I really would need this hook, because it would replace multiple additional hooks for my plugins.
First im able to add the invitekey field without an additional hook, and second, also profile fields could be added without some add_js workaround.
[Hook] Re: Custom Fields
« Reply #4, on November 17th, 2014, 05:59 PM »
Thought about this again, and didnt found a way to integrate it in a good way. Some problems i found regarding this problem.
There are some areas where it would be nice to modify the fields. Just some which popped up in my mind are memberlists, membersearch, short summary on topics, normal profile summary.

In normal profile summarys its only possible to hook onto $custom_fields, but thats ugly, because its to hard to rework the way of how custom fields work. For example privacy would not work properly, you would need to hook there in too. A in my opinion better solution would be for example an array like menu_items for all profile fields (in summary).
Code: [Select]
profile_fields = {"general" = {"title" = "General",
                                            "fields" = {"username" = {"name" = "Username", value="CerealGuy", privacy = false},
                                                            "location" = {"name" = "Location", value="Germany", privacy = true}
                                                           }
                                           },
                        "userspecific" = {"title" = null,
                                                 "fields" = {"ip" = {"name" = "IP", "value"="127.0.0.1", "show"=$context['can_see_ip']},
                                                                "language" = {"name" = "Language", "value"="German", "privacy" = true}
                                                                }
                                                 },
                       "custom_fields" = {"title" = null,
                                                    "fields" = {"likes_recieved" = {name= "Likes recieved", value="<a href=........>15</a>", "privacy" = false}
                                                   }
                       "invites" =  {"title" = "Invites",
                                         "fields" = {"invited_by" = {"name" = "Invited by", value = "<a href.....>Blubb</a>", "privacy" = true},
                                                         "invited_users = {"name" = "Invited users", value = "<a href.....>User1</a></br><a href....>User2.....", "privacy" = true}
                                                       }
                                         }
 

                       
                       }


As you see it would be easy to create a new profile area and manipulate them. Privacy true/false would just set if privacy is enabled or not for that field. Show same like in menu_items. Another idea is that you could set names for different areas to seperate them more. Also custom fields could just extend profile_fields[customfields].

Yeah some more or less crazy ideas, dont know what you think about them. Would love to read some comments on this.