News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

How to have a non-admin edit custom profile fields?

Started by dsmclaughlin22, May 12, 2015, 06:20:58 AM

Previous topic - Next topic

dsmclaughlin22

Hi folks,

My users have two custom profile fields, on which the permission is set to "Users can see this field; only admins can edit it".

My problem is that I would like a particular Member Group to be able to edit this field for any other member - without giving that user group full admin rights.

I cant seem to figure out how to do this through granting permissions through admin control panel (if there is a way I'd love to know how).

So, I though I could make an edit in the php to check for the Id of the member group that should be able to do this and then show those two fields as appropriate.

I would really appreciate it if someone a) could let me know how to do this without making any code edits or b) point me in the direction of the code I would need to edit.

Many thanks!

~Drew

margarett

No, I don't there there is a way... It's buried in the way permission operate, I'm sure that it can be done but I would suggest it's not an easy task...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dsmclaughlin22

Thanks for your Reply margarett!

That is unfortunate indeed.

What about taking the other approach and hiding the admin panel from the user group who I want to be able to edit the profile, do you know where I could edit the code to do that?

margarett

No, that's not the problem. The field is changed in the user's profile, so no admin panel is required. The "thing" is that the user must also be able to edit other user's profile.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dsmclaughlin22

yes I agree,

but I could just hide admin functionality from the admin member who has the power to edit the custom fields based on their member group?

margarett

An admin has explicit permissions in many many more places (everywhere, basically :P ). I would seriously advise you NOT to go down this route...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dsmclaughlin22

ok fair point, thanks for your wisdom :)

Anyone else know how I might accomplish this?

Illori

IMO if someone knew how to do it, it would be margarett. i really dont see how you can do this any way.

dsmclaughlin22

That's a shame, I would really need to be able to have non-admin members who can edit other users fields :(

margarett

I would only suggest doing it by creating a new section in profile with its own permission. That page would list all user's custom profile fields and allow the one with the proper permission to change them.
But that's not really an easy task, at all... And since it's really a "niche request", it's not something likely that someone out there already did it/will do it for you, unfortunately :(
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dsmclaughlin22

I like the idea, maybe it's time to really get to grips with the SMF code base.

Any good articles on how to run locally and develop, is there a github project I can fork or similar?

margarett

Actually most of what you need is already out there :P

There is no "article on how to develop" :P You just need a local setup of SMF through XAMPP, WAMP, etc, SMF itself, a code editor (Notepad++ is perfect) and a *LOT* of perseverance ;D

What you need is to create a MOD. Be it hardcoded in your files or as a "full" package (which I would recommend, this way you can easily reuse it if you need it more than once - chances are that you actually do ;) ). The best way to learn about MODs is to pick existing MODs. And read. Sorry, there is no "crash-course", you really need to get your hands dirty :P

How to add a new section to the profile? This MOD of mine does that, you can it as a "base" of a MOD, how it interacts with hooks, how to load text strings, etc:
http://custom.simplemachines.org/mods/index.php?mod=3890

Create a permission is also easy, there is a great guide by Arantor (that I can't find off-hand...)

Then, the necessary code to load the custom profile fields and change them is already there in Sources/Profile-Modify.php and Themes/default/Profile.template.php. You obviously need to adapt some stuff to show all profile fields and so on... And here lies the difficulty, really...

Good luck ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dsmclaughlin22

cheers margarett!

Your last post will be very helpful.

I've already had smf running locally on XAMPP and I have a text editor :)

Out of interest how do mods work exactly? I've installed a few and seen that they run tests, and change files, but what's going on? do they just replace parts of the SMF source with their own or replace whole files or...?


margarett

http://wiki.simplemachines.org/smf/Modifications/Mods_-_What_is_a_mod

MODs are pretty much "extensions" of code that somehow change SMF's default behavior. They can do a vast amount of things, from small template changes (eg, remove the logo) to major overhauls (eg, portals).
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dsmclaughlin22

super! I'll see how I get on with that... #wondersOffToAQuietCornerWithHisLaptop

Steve

As your questions appear to have been answered, shall we mark this solved for now? It can always be marked unsolved later if you have more questions. :)
DO NOT pm me for support!


Steve

Thanks. Wouldn't mind knowing how you get on with what you're doing later on. :)
DO NOT pm me for support!

dsmclaughlin22

If I get anywhere with it I'll be sure to share!  ;D


dsmclaughlin22


Advertisement: