1

Re: Members List display of s2member custom fields

Daine, there are many plugins that store the meta data for users in ways that aren't native to WordPress. As you probably know, WordPress stores meta data for users in its wp_usermeta table. This is where the Members List plugin draws from and it will only draw from strings or numerals in the database. This isn't something that will change as it is my belief that this is how plugin writers should store user meta data because it is the way WordPress intended. Usually I write my own plugins when I need additional fields available for users.

Re: Members List display of s2member custom fields

I agree and indeed, the data is stored in the sql table.
The trick is though that instead of many separate custom fields, they only use one field and as I noted, store the custom data in a JSON-encoded array.
In some ways more efficient than creating a slew of fields which may or may not be used but not as easily accessed by folks like me.

And while I have some programming background, I am far from ready to create my own plugins.

DP   

Re: Members List display of s2member custom fields

Indeed, thanks...

I was looking through the folders earlier today and suspected that was the one where I needed to be but it is pretty dense for an inexperienced php guy like me :-)
I will see what I can do with it.

Can I ask an unrelated question, do you use a particular program while developing php code?
At the moment I am just using notepad in windows which is obviously not exactly the most useful environment. I mean, it doesn't even have line numbers.
That said, at the moment, I am doing everything on the server so I am not so sure how useful a real php IDE would be.

Thanks, Daine

Re: Members List display of s2member custom fields

Daine,

I uses TextPad to do quick editing on the server. Easy line numbers etc.

I also needed to list the members with s2Member and was having the same problem, so this thread has been very helpful.

The key to reading s2Member custom fields correctly in that loop is:

<code>
$customdata = $u->$v['name'];
</code>

Then, $customdata is just an array with all of your fields in it and you can call them as needed with $customdata['custom_field_name'] within that loop.

I'm using this a little differently to populate member address information into Google Maps API, so I destroyed that markup function a little more that you would for a normal list, but that should get you started.

- Dan

Re: Members List display of s2member custom fields

I am not using s2Member, but am using MagicMember and am running into the same problem, the user fields were not saved into wp_usermeta. I see that some of you have figured out how to manual code to add the custom fields you created in your Membership Plugins to be able to be added to the MarkUp page of this plugin, would you mind copying the full code that you used so that others might be able to do the same thing?

Thank you

Re: Members List display of s2member custom fields

I think I may have miss-typed above, the fields are saved into wp_usermeta but as one field also, mgm_member. Would you be able to point me to where I should be adding this code?

$customdata = $u->$v['mgm_member'];

$customdata['custom_field_name']

Thanks

Re: Members List display of s2member custom fields

I'm trying to inserting total post count of every author after display_name or email but don't know how to add it in the member list. can anyone please help me?

8

Re: Members List display of s2member custom fields

gspiash, you'll need another plugin that will store this data for you in the wp_usermeta table.

Re: Members List display of s2member custom fields

phone_number is my custom field from s2Member.
How can I display it with members list plugin ?
Because I add a s2Member custom field in Mark-up but it display "Array".
I read your code pxlcreative but I don't know where I have to right it.
Thanks
Cédric

Re: Members List display of s2member custom fields

cedric, it sounds like s2member is storing the data in a serialized array in the database. Meaning when the information is retrieved from the database it parses it and turn it into an array in PHP. The members list is only capable of retrieving strings from the database to print to the page. A string is plain text instead of a list of elements.

Re: Members List display of s2member custom fields

Is there a way to parse the data in the array if you know the index of the array item? I am trying to make a member list using s2member and I just need 2 additional items, Profession and hobby. They should be items 6 & 7 in my array. The items before them I am not interested in displaying on the site member page.

Re: Members List display of s2member custom fields

If you find a way to parse the data in the array, share it please ^^

Re: Members List display of s2member custom fields

I am trying to work on it as we speak. s2member custom fields do show up in the member list plugin. So member list can load the variable array, I just don't know how to specify that I want to display the 3rd element in the array. I have been on the s2member forum and they have been more helpful over there. I just don't know enough about php to get it to work yet. I really need to load just two of the custom fields I created. I even tried switching to another plugin and member list cannot see any of the variables it has created.

Re: Members List display of s2member custom fields

Ok, I am trying to insert this code into the markup.
*****
<li>
    <div class="tern_wp_member_info">
        <div class="tern_wp_members_display_name">admin</div>
        <div class="tern_wp_members_user_email"><a href="mailto:ngentile@gmail.com">ngentile@gmail.com</a></div>
        <div class="tern_wp_members_wp_s2member_custom_fields"><?php echo get_user_field("user_hobby", $user_id); ?></div>
    </div>
</li>
******

The third line where the s2member custom field is being referenced I am trying to use the get_user_field call to pull this is. It won't work in the markup here but when placed in the same page after the member list it will execute and print on the page. Any ideas?

Re: Members List display of s2member custom fields

Also, Why is it that I can only select s2member custom field one time from the list? I need to grab at least 1 more custom field.

Re: Members List display of s2member custom fields

I think there is only one custom field variable but this is an array with as many fields as you select with s2Member.
I think your code didn't work because member list couldn't use get_user_field.

Re: Members List display of s2member custom fields

I agree, but even though it is in an array it won't let you add anything else to the markup that has that argument in it. So if I wanted to access :
<div class="tern_wp_members_wp_s2member_custom_fields"> again I can't even add it since once it has been added to the markup you can't add it again.

Also, I found another API we could use to reference the info we need in the form of an s2 shortcode, no php etc. [s2Get user_field="user_hobby" /]  You would obviously change the user_hobby to whatever the field you are trying to collect would be. The funny thing is that it renders that code as a string when it processes the page, but when I add the shortcode outside of the memberlist long code it does return the value for the logged in user. So in reality the problem must lie within memberlist plug as it does not process php or allow shortcodes inside of the markup. How can we get around this? Why won't it process the shortcode or php (btw, I am using php-exec to process php in posts and pages and it does work on other pages other than the php code I am trying to force inside of the member list markup)

Re: Members List display of s2member custom fields

<div class="tern_wp_members_wp_s2member_custom_fields"><?php echo get_user_field("user_hobby", $user_id); ?></div>

Adding PHP (like above) directly to the mark-up will not work.

Currently this plugin is set up to receive strings from the wp_usermeta table. The plugin, in attempt to be compatible with a wide range of plugins, checks the database table wp_usermeta for all names of user meta fields. This is why you see the titles of the fields you've set up with s2member.

The plugin only sees values that have been filled out because again it looks directly to the wp_usermeta table to find fields it could post.

Any fields containing information other than strings will not render as you'd like them to. This plugin was not designed to parse and deal with serialized arrays. Think about the search features of the plugin. In the event that you set up a field called "city" and you wanted the users of your site to be able to search through your users by city, a query needs to be created to allow this to happen. MySQL does not have the capability of parsing a serialized array while querying. Storing the "city" information in a serialized array would break the query.

It does not make sense to store data in the wp_usermeta table as an array or in any form other than a string or integer. This is how the table was meant to be used. Plugins that store the data in ways other than strings or integers are not playing nice. They make it significantly more difficult on other plugin developers.

The Members List plugin will not offers this capability. You'll need to find a plugin that allows you to add fields and stores them properly in the wp_usermeta table.

Re: Members List display of s2member custom fields

Thank you for replying. I found that s2member supports some direct fields access in its API. So I can use a shortcode to access a specific field in the array. For example, [s2Get user_field="user_hobby" /]. I tried plugging this in with no avail. So I imagine from what you are saying no kind of code will render in this plugin?

Re: Members List display of s2member custom fields

That is correct. The do_shortcode WordPress command is run when rendering content using WordPress' the_content function. Shortcode is not run when compiling the fields for this plugin.