latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Displaying labels as opposed to option values

Home Forums Community Forum Displaying labels as opposed to option values

This topic contains 10 replies, has 3 voices. Last updated by  epsilonweb 4 years, 9 months ago.

Topic Author Topic
Posted: Thursday Mar 1st, 2012 at 9:01 am #6884


First I would like to mention how impressed I am with the S2member plugin. I tested the free version and was so pleased that I decided to buy the pro version even if I don’t need the extra features.

My question is about how the labels of the custom profile fields (more specifically Select Menu or Checkboxes) are displayed on the Browse Members (or All users) admin page. For some reasons the option value are displayed as opposed to the option label for the Select Menu or Checkboxes. This is an issue when searching for users with specific custom profile fields.

Searching the forum I came across a thread : Getting Custom Field values on the frontend

I manage to extract the labels, but I would much appreciate a sanity check and suggestions on improving the robustness of the preg_match call.

$field_id = 'your_unique_feild_id';
$s2_custom_fields = get_s2member_custom_fields($user->ID);
$list_to_match = $s2_custom_fields[$field_id]['config']['options'];
if (is_array ($s2_custom_fields[$field_id]['user_value']) && count ($s2_custom_fields[$field_id]['user_value']) > 0) {		
	foreach ($s2_custom_fields[$field_id]['user_value'] as $option_value => $option_label) {
			preg_match("/$option_label|(.+)/", $list_to_match, $result);
			echo $result[1];
			echo "<br/>";

Where I struggle a little more is how to best integrate that within the code of the file in order to replace the option value with the option labels. I think found the section where they are displayed, but I would much appreciate if you could suggest how it should be integrated.

echo '<td>' . c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_profile_", "ws-plugin--s2member-profile-", "", ((preg_match ("/^(text|textarea|select|selects)$/", $field["type"])) ? "width:99%;" : ""), "", "", $fields, $fields[$field_var], "profile") . '</td>' . "n";

Thank you in advance,

List Of Topic Replies

Viewing 10 replies - 1 through 10 (of 10 total)
Author Replies
Author Replies
Posted: Friday Mar 2nd, 2012 at 3:45 am #7019

Thanks for the kudos and your support! :)

I’m not completely sure I understand what the problem you’re having is. Could you post a screenshot of how the column for that field looks for you in the list?

And a screenshot of your custom field definition? [hilite path]Dashboard -› s2Member® -› General Options -› Registration/Profile Fields[/hilite]


Posted: Saturday Mar 3rd, 2012 at 3:57 pm #7188

Hi Cristián,

Thank you for the prompt response.

I prepared a combination of screen shot describing my observation. I am not sure if this is the recommanded method to share images on this forum.

option label image

I highlighted the different between how select menu options are displayed on the “All Users” page compare to the “your profile” page.

Thank You,

Posted: Saturday Mar 3rd, 2012 at 11:08 pm #7211

Ah, I understand now what you meant. Thank you very much for showing me the screenshots.

I agree that it should be the label the one shown there. I’ll mention it to Jason.

Posted: Monday Mar 5th, 2012 at 4:33 am #7333

Hi Cristián,

I also noticed that the field ID (as opposed to the label) are displayed for the column headers. Therefore it is not possible to display special characters required for other languages (see image for details).

Field ID as opposed to Label

Thank you very much,

Posted: Tuesday Mar 6th, 2012 at 1:42 am #7393

Thank you, Patrice!

Posted: Monday Mar 19th, 2012 at 1:40 pm #8551

Hi Cristián,

Do you know if Jason had the chance to look at this ? If he can give recommendations, I would be happy to hardcode this in the plugin for the moment.

Thank you,

Posted: Tuesday Mar 20th, 2012 at 2:15 am #8575
Staff Member

Hi there. Thanks for the heads up on this thread.

@epsilonweb: I’ve just taken a look at your report on this.
There are two issues here, and each of them has obstacles to overcome, before they could be changed.

1. The reason we show option values instead of option labels in your list of Users, is because each User may have values that no longer exist in the current configuration of a particular Registration/Profile Field. For instance, if a customer registered in Jan 2011 when you had a different set of options, we need to show the values they actually have, which might not be available in your current configuration.

2. The reason we show Field IDs in the column heading, is because many site owners use HTML code in their Registration/Profile Field labels, which can create clutter in a list of Users. So using the ID is a way to avoid this. However, I agree that we need to work at overcoming these issues, and we’ll certainly keep your suggestions in mind as work continues on the next generation of s2Member.

In the mean time, if you’d like to update your copy of s2Member, so that Labels are used in column headers, you could make the following change, if you like.

In file: /s2member/includes/classes/ at line #141 find:

$cols["s2member_custom_field_" . $field_var] = $field_title;

Change that to the following:

$cols["s2member_custom_field_" . $field_var] = $field["label"];
Posted: Tuesday Mar 20th, 2012 at 5:14 pm #8648

Hi Jason,

Thank you for your response, I appreciate the potential pitfalls and thank you for pointing out how to display the labels for column headers.

It would be much appreciated if you could also give me a custom solution to display the option labels?

Thank you,

Posted: Friday Mar 23rd, 2012 at 7:05 am #8895
Staff Member

Hi Patrice. You’re very welcome.

So sorry, that additional modification you requested would take a more in-depth approach (i.e. more than just a line or two of code). In order to accomplish this, you would need to make some further adjustments around and just below line #206 inside

See also: s2Member® » Support Policy » Fine Lines

Posted: Friday Mar 23rd, 2012 at 2:03 pm #8942

Hi Jason,

I understand. I will give it a go and share my solution for feedbacks.


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

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.