Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to customize profiles, and create profiles specific to User Roles.


  • mrapino
    Participant

    @mrapino

    Hello everyone! I know this has been a topic in the past, but I was hoping for a more complete answer to this issue. I know there are many people who would benefit from a viable solution to this.

    First off, I am using WordPress 3.9.2, and Buddypress 2.0.2.

    The main purpose of this post is to try and figure out how to create multiple profiles (2 or more) with completely different profile fields, and to associate each profile to a different user type/user role.

    Example: I created to custom user roles … Writer and Publisher. We have Anthony, the writer … and we have Jason, the publisher. When you click on Anthony’s profile, you will see an author bio, other writers that influenced Anthony’s work, favorite genres, etc … When you click on Jason’s profile, you’ll see the publishing company that Jaosn works for, maybe a company about section, if it is a large publishing house … how many employees, how many writers are published, etc…

    What I am looking for is one of a variety of things… I will, of course, be thrilled if one of you has a full code snippet/snippets that does what I am looking for. I will also be appreciative for an explanation of what Buddypress files need to be edited to achieve this. Really, anything that gets me closer to a solution, as I am currently doing this for a client’s website, and after I finish this piece of functionality, we will almost be finished!

    Thank you so much for reading this, and thank you in advance to all of those willing to help me achieve this goal.

    Ask me any questions you may have that will help clarify things.

    Cheers!!

Viewing 11 replies - 1 through 11 (of 11 total)

  • mrapino
    Participant

    @mrapino

    Bump


    danbp
    Moderator

    @danbp

    hi @mrapino,

    i have no ready to use answer but study or try this plugin:
    https://wordpress.org/plugins/buddypress-conditional-profile-field/

    I don’t think you have to touch any buddypress file, except the profile templatevia a chil theme and to add some custom function or create a complete plugin, to achieve your need.

    Anything concerning directly profiles is in /buddypress/bp-xprofile/ folder.
    Maybe not a big help, but it’s all i could tell you for now. 🙁


    mrapino
    Participant

    @mrapino

    I appreciate your response! I will take a look at this plugin. I am always hesitant to use plugins that are so out of date, but perhaps there is some code within the plugin files that will be useful.

    Also, is there any resource that details the functions available within Buddypress. I have looked at the Codex, but I can’t seem to find a nice definitive resource. The WP Codex has all of the actions, filters, functions, etc… I was trying to find something similar within the Buddypress website, but can’t seem to find documentation that has everything detailed out. Is there a lot of documentation that hasn’t been written yet, or am I just looking in the wrong place?

    Please keep me posted if you have any other suggestions about what functions, or code snippets I might use to gather the correct information to alter the profile section based on user roles.

    Basically, I need to know where you might place the custom code (is it within the bp_custom file?) And if I use bp_custom, I am guessing I would have to hook my code into the correct location, so Buddypress knows to enact my code correctly (Is there an action hook that hooks into the Profile section specifically?) I also would need to know where to find the functions I need to edit the profile section (all xprofile functions, any functions that might help me attach user roles to profile fields, any functions that pull data relevant to the connection between profiles and users, etc…)

    Regarding the connection between user/user role and profile, would I be calling these functions separately … meaning, would I first use a conditional to see what user role the user is, and then within that conditional be using general xprofile functions to display only the fields I want to display for the user role that the conditional is specifying?

    I think if we all start to spitball ideas, this post can be a sounding board for the code that can build this functionality out. In my research over the past week, I have found so many incomplete conversations about how to make this functionality a reality. So, I know there are many people looking to do exactly what I am attempting. And the beauty is that we all have bits and pieces of this idea and how it might fit together. Perhaps we can all start posting our code snippets here to build this out together?

    If we can make it work, I bet this post can be the beginning of a core Buddypress code update that can integrate this into the actual Buddypress Core.

    What do you all think?

    I’ll be continuing my research and posting my findings here. Let’s make this happen!


    danbp
    Moderator

    @danbp

    The best place to get BP commented code is in the plugin files. Raw, when you don’t know exactly what to search.

    Notepad++ is a good software to accomplish this localy.

    Another good ressource is the Trac !
    https://buddypress.trac.wordpress.org/report

    The’re also online search engines like
    http://phpxref.ftwr.co.uk/buddypress/nav.html?index.html
    http://hookr.io/# (WP specific)

    In your case, customizing profiles would certainly start at the registration step, to fill in a (long?) form. So the first thing to get, is such a conditionnally form.

    See Gravity Form or Formidable Pro. No idea if they integrate well to BP….

    Your question about bp-custom is explained on the codex.

    Defining a role is a large domain.
    When you ask people for their interrest, knowledge, etc you finally get a good idea of what they are or can do or represent. Once you know that you give them a role.

    In other cases, you attribute them a role before knowing anything about them (eg. default subscriber role in the WP sphere). In this case anyway a pseudonym is enough. No need of extended profile field.

    IMHO it depends of the strategy you want to apply to your visitors. And this is not a support question.

    If we can make it work, I bet this post can be the beginning of a core Buddypress code update that can integrate this into the actual Buddypress Core.

    Ambitious at least. I’m affraid you’re many steps away of this for the moment. Man lives by hope ! 😉


    mrapino
    Participant

    @mrapino

    Thanks for the links.

    Defining a role doesn’t necessarily require previous input from the people using your site … you simply define the roles of your users based on what you want those users to be. Custom user roles allow you to have more granular control over what your users can do and see when registered on your site. Regarding Buddypress … I think that having a way to pre-define user types/roles and assigning custom profiles to those various user types is something to be desired.

    I am using Gravity Forms to create a custom registration form that allows a registrant to pick the type of user they are and when the user type is chosen, I am conditionally displaying custom fields that are associated to the specific user type.

    The problem is that after the user registers, and the fields are filled out, if they go to their profile to edit the information, they see ALL FIELDS regardless of the user role they chose during registration. The reason is that although Gravity Forms allows you to map certain fields on the form to profile fields in Buddypress, you still have to edit Buddypress to HIDE the fields you don’t want those users to see.

    That is why I am posting this question … I am trying to get code together to alter the profile section of Buddypress to allow you to associate specific profile fields to a user role, so when the user of a specific role finally goes to their profile to make edits, they do see, and are not allowed to edit fields that are not associated to their specific role.

    IMHO this type of control is very useful, as it can help you create some fairly interesting communities.

    Thanks for your assistance. I hope I have clarified things further for you. If anyone can help, great … if not, I am still moving forward on this and when I come up with a solution, I will post it here. If anyone can help me get to that solution faster, I’d be very appreciative. If not, I hope I can help those of you who are looking for the same results.


    danbp
    Moderator

    @danbp

    see fetch_visibility_level in bp-xprofiles-classes.php:393 if it helps you to go further.


    mrapino
    Participant

    @mrapino

    I think I am onto something. I have a post I am trying to submit with some code snippets, but it isn’t going through. I’ll try a couple other things…


    mrapino
    Participant

    @mrapino

    Am I not allowed to submit code snippets? I keep getting an “ERROR: Your reply cannot be created at this time.”


    danbp
    Moderator

    @danbp

    It happens often.
    Better to post your snippet on pastebin or github and give the link


    mrapino
    Participant

    @mrapino

    Okay, this is my first piece: http://pastebin.com/pyz8XaaP

    This first link is some code findings that might continue the conversation toward an elegant solution.

    And then I came up with another possible solution here, which is actually partially working, but might be a bit clunky: http://pastebin.com/3JBCuZrx

    Basically, the first link is not working, but may give us more food for thought. The second link is working, but there are a few caveats. What I am doing in the second link is finding out what user role the logged in user is attached to. Then I create a conditional that states that if the user is under a certain role, it hides the profile group tabs from being seen, which essentially prevent them from adding content to them, and if there is no content for any of the fields in the group, it won’t show on the front end.

    CAVEAT: if you go directly to the profile group URL, you can still edit. I need to figure out how to actually prevent the URL from working, as opposed to/ or in addition to hiding it.

    Either way, I think there’s a bunch of good stuff to talk about here.

    Let me know what you think.

    NOTE: I am using some code found on this post:
    https://buddypress.org/support/topic/conditional-exclusion-of-a-xprofile-fields-group-from-editing/


    danbp
    Moderator

    @danbp

    I’m not a developper so i can’t discuss more with you.

    Also be aware that BP 2.0 -> 2.0.2 is a little buggy and not able to handle correctly profile groups in some cases. It’s fixed in trunk for 2.1.

    More details on this topic

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How to customize profiles, and create profiles specific to User Roles.’ is closed to new replies.
Skip to toolbar