[Membership 2 Pro] Allow users to change display name

I would like to allow users to change their display name in the Account interface on our membership site like Wordpress does when you edit your User Profile (https://codex.wordpress.org/Users_Your_Profile_Screen). Is there a way to add that "Display name publicly as" dropdown to the Account page? Or to allow users access to their Wordpress backend profile without giving them access to any other backend pages?

  • Ash
    • WordPress Hacker

    Hello creativewebguru

    Yes, this is possible :slight_smile:

    Please go to Dashboard > Membership 2 > Addons > And enable Profile Fields addon. Then go to Dashboard > Membership 2 > Profile Fields and you can select which fields you want to show on the registration form and edit profile screen.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

  • creativewebguru
    • Design Lord, Child of Thor

    Ah, good. Thank you, Ash. Now people can access this by clicking "Edit" next to Personal Details on the Account page. This is a good start.

    But the additional fields don't display on the Account page itself. I'm looking at the code in template-tags.php and there's a get_ms_ac_profile_fields() function but I can't tell how it decides which fields to grab. The membership_account.php seems to call this function to display things on the Account page, so I feel like I'm on the right track but not sure where to go from here.

    How can I get those additional fields to display on the Account page itself? (I activated 'Display as' and 'Website'.)

  • creativewebguru
    • Design Lord, Child of Thor

    UPDATE: I found in the Membership 2 > Help page under Customize Membership 2, that I can customize my own version of the Account page by creating m2-account.php and putting it in my theme directory.

    I copied the contents of membership_account.php and put them in m2-account.php and made some small changes, but my site does not appear to be using that page. It's still referencing and displaying membership_account.php. Any tips?

  • Ash
    • WordPress Hacker

    Hello creativewebguru

    Are those custom additional fields or BP xprofile fields? If BP xprofile fields, then it should appear on the profile fields addon section. If those are custom fields made by another plugin or programmatically, then you need to edit the templates.

    Here is an example of implementing custom field for M2 registration: https://gist.github.com/bappi-d-great/6ede4f0b9a524c80047e1801515f665b

    You can get an idea how you can show the custom fields in the membership account page as well.

    Hope it helps! Have a nice day :slight_smile:

    Cheers,
    Ash

  • creativewebguru
    • Design Lord, Child of Thor

    Thank you for the example, Ash, that's helpful. We're not using BuddyPress (if that's what you were referring to when you said 'BP xprofile fields'). There's a problem, though.

    I'm seeing a strange glitch. When some users go to My Account and clicks Edit next to Personal Details, it shows them the profile fields BUT the "Display As" is set to "Havok" and the "Website" is set to "https://gohavok.com". And no matter what I select or type in, it returns those two fields to those settings (it does not save my edits).

    My goal was to allow people to add/change the default Wordpress-related user profile fields (the ones that I - as an admin - can see associated with each user profile in Wordpress). Specifically these three:

    Nickname
    Display As (dropdown menu)
    Website

    This mystery has some clues, but I don't know how they fit together:

    Clue #1: The only fields in my installation (that I know of) that have the "Havok" name and "https://gohavok.com" website are from a "Guest Authors" custom post (related to the Molongui Authorship plugin).

    Clue #2: Everything appears correct until someone edits their profile fields. Then after saving their changes for the first time, the Display As and Website fields have the wrong data.

    Clue #3: The logout phrase at the bottom of the Account page now says "You are logged in as Havok" (instead of reflecting the correct username).

    When using the Profile Fields add-on for Membership 2 Pro, how does it pull those fields (where does it get them, where in the code does that happen)?

  • Ash
    • WordPress Hacker

    Hello creativewebguru

    It may also happen if you have any other plugin/code which is forcing to not change those fields. Because, I have just tested on my site and I could save those fields. Would you please run a conflict test? Please deactivate all plugins except this one and check if the problem gone. If so, then enable all plugins one by one and find which one is having conflict. You need to do the same with themes as well.

    You can find the flowchart here: https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-1

    If there is no conflict, would you please enable support access so that I can check? Please follow this article to enable support access: https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-5

    Also, leave a test user's username and password in the "SUPPORT ACCESS" area so that I can check the issue.

    Have a nice day!

    Cheers,
    Ash

  • creativewebguru
    • Design Lord, Child of Thor

    Yes, so sorry for mixing the two threads! The answer to one ended up creating a second issue and I thought I should keep them separate but then I put info in both. Oops! I'll follow up on the second thread.

    This one is resolved because the initial request was how to allow users to change their display name -- which was answered by installing the Profile Fields add-on.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.