[s2Get user_field="my_field" /] stopped working

Hello,

I am new to s2 member (pro), I generally like it. I have just upgraded to v241216 (Framework and Pro) from v241114 (Framework and Pro) and none of my [s2Get user_field=“my_field” /] short codes now work? Anyone else have this problem?

Thanks in advance,
Rob

Thanks for reporting that, Rob!

I’ll take a look at it to fix it in the next release. You can use the previous version in the meantime if you want.

:slight_smile:

yes, this has stopped for me as well.

Till it gets properly fixed this does the same job

function s2GetPro_shortcode($atts) {
	$atts = shortcode_atts(array(
		'user_field' => ''
	), $atts);

	$user_id = get_current_user_id();
	$custom_fields = get_user_option('s2member_custom_fields', $user_id);

	return $custom_fields[$atts['user_field']];
}
add_shortcode('s2GetPro', 's2GetPro_shortcode');
1 Like

I sent you a few private messages during the past couple of months but I am unsure if you’re reading them.

I was unable to email you as well.

Just letting you know in case you’re unaware.

If I don’t get an answer I will assume it’s intentional and I won’t waste my time here.

1 Like

Hi Sim! Wasn’t intentional. I’ll look for them now.

1 Like

Nice, Gerard. :slight_smile:

I’ll improve this in the next release.

1 Like

Rob and Gerard, I made a release today that includes a fix for the custom fields in s2Get. https://s2member.com/s2member-v250214-now-available/

:slight_smile:

1 Like

I just experienced a similar problem. Reporting here because the code here fixed it for me.

  1. User visits a page that displays a custom profile field using S2get
  2. User updates custom profile field using the profile page
  3. User revisits page that displays a custom profile field using S2get
  4. The page displays the old data
  5. User revisits the profile edit page and it displays the updated data (and so does the admin page)

First I thought this had to do with moving to a new host and caching because it was reported by a user days after a host move, but I was able to replicate on a local install with no caching. I tried downgrading to the last few s2 versions along with a random one from 2023 and still experienced the error.

I put Gerard’s code into my theme functions.php file and changed the custom profile field s2gets to that one and it worked as expected. Note, though, that it only worked with the custom fields. Using the new shortcode on non-custom fields gave blank responses. So what’s currently working is s2Get for the native fields and s2GetPro for the custom ones.

Confirm.

Ric, are you using v250214 or newer? And with the latest release you still can’t display custom profile fields with s2Get? It’s working for me, so could you give me more details to reproduce the problem? Same you, Krum, if you could give me more details, please. Thanks!

:slight_smile:

Yes. I was using the latest version and tried a few earlier ones but still had the concern. Haven’t tried the latest-latest just released one, but it’s working with the modified s2get above so I’m not changing things for now. I had put a copy of my live site on a local instance, disabled all plugins, and went with a standard theme and still had the error of the data not showing as updated after a data update.

Thanks for the update. Did you try with different custom fields and didn’t work with any? Could you tell me the custom field’s configuration so I reproduce it on my side to try it with s2Get too? Thank you!

:slight_smile:

This was a text (single line) field.

Maybe you could give just a little more detail?

The more detail you give the better as software is COMPLEX.

@Gerard I wrote instructions above that show how to recreate the situation. Another user was able to reproduce the issue from that. I also provided the field type when asked for it. I’m not sure what else you think I can provide.

EDIT: Also, since your code FIXED the issue (but only worked with custom fields) maybe there’s a difference between implementations?

I tried duplicating the issue on a brand new Local (wp engine’s thing) install, but couldn’t. However, it still occurs on the existing website in staging on a Local install in addition to the live install. Disabled all plugins, used the default WP theme, deleted all mu-plugins, added all the no caching flags to wp-config (even though caching isn’t configured), and even deleted all my users but myself in case there was some legacy data in the tens of thousands of users causing it. But it still occurred. It’s not urgent bc @Gerard 's code fixed it and maybe it’s some legacy thing since this site has been up since 2012. Maybe @krumch can figure it out since he confirmed the issue exists and has way more PHP experience than I do.

1 Like

Thanks for all the additional details! I wonder what’s going on there… Would be good to know in case it needs a fix in the release.

@krumch could you tell me more about how to reproduce the issue on my side? Thank you!

:slight_smile: