Add custom fields to Membership Edit Profile form

Add custom fields to Membership Edit Profile form and also show value in the account page. I am creating the fields in Pods - Custom Content Types and Fields plugin and activate the profile fields addon but the fields are not showing in the Addon like it shows for buddypress custom fields.

  • Adam Czajczyk

    Hello Talal

    I hope you're well today and thank you for your question!

    I have checked this on my own setup and I can confirm that those user fields created by Pods plugin are not visible to the Membership 2 Pro plugin. However, there's a solid reason for this.

    That's a bit "tricky" issue I'm afraid. The value of a "Pods-created" user profile field is properly stored in a _usermeta database table, after a user profile is edited. The information about the field itself is stored as a custom post in posts table which is also fine, I believe. The question is how does the Pods plugin actually "hook" these fields to the user profile. I'm not sure about that but that seems to be the issue.

    I'll need to consult that with our developers so I have already asked the to check this and am awaiting their response. Please note: it's not a bug but rather a compatibility issue related to the way how the Pods plugin code interacts with WordPress itself. Our developers are dealing with a a lot of complex stuff on daily basis so their response might be slightly delayed but we'll update you here as soon as we got feedback from them.

    Kind regards,
    Adam

  • Panos

    Hey there Talal ,

    Membership plugin uses the user info that it needs in order to function and send the appropriate information (first name, last name etc) in the notifications.

    You use a 3rd party plugin, so it requires some custom coding in order to have an integration with the Pods framework. Membership plugin, provides filters (and a few templates) so those fields can be extended. Depending on the detail you need, you might require a developer to accomplish this, however I have prepared a custom mu-plugin which should cover basics and can be used as a guide. You can download file from here:
    https://gist.github.com/wpmudev-sls/bdbd70089d2769ead0f663d19517856b

    Unzip it, and upload the php file to your wp-content/mu-plugins folder. If that folder doesn't exist already you can imply create it.

    Hope this helps!

    Kind regards!

  • Panos

    Hey Talal ,

    There's no such plan of what I know of.

    There is a huge number of plugins for user fields, so best solution is to provide filters that can be used and make up a custom integration. As the snippet provided above. It should provide the basic functionality as it is. I have tested it only with text fields, I haven't tested with more complex field types. This is mainly for the edit page.

    With the text fields it worked fine in my tests. The mu-plugin calls the pods function to load the edit form, so theoretically it should work for all field types that pods provides. But we can't guarantee that.

    You can give it a try and let us know if there is something specific that does not for you. If it's simple we could have another look :slight_smile:

    Kind regards!

  • Adam Czajczyk

    Hello Talal

    As far as I understand this part of the code (the query that is fetching pods) should be limiting only to the pods of "user" type:

    $args = array(
                    'meta_query' => array(
                        array(
                            'key'       => 'type',
                            'value'     => 'user'
                        )
                    ),
                    'post_type'         => '_pods_pod',
                    'posts_per_page'    => -1
                );

    While the pods are stored as "_pods_pod" custom post (posts of custom type), the specific type of a given pod is set as a meta_value ("user" in this case) of a "type" meta_key for the post (in _postmeta table). The query above is meant to fetch only the pods of a "user" type then.

    Isn't it doing that for you or do you mean limiting to some specific fields rather than type or to a specific pod by the name of it? By the latter I mean a case when you e.g. have multiple pods of some type named for example "something", "another" and "user" and you only want to fetch "user" picking by the name of the pod?

    Let me know please and I'll ask Panos to take another look at it.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.