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.

Syncing custom field with standard field

Home Forums Community Forum Syncing custom field with standard field

This topic contains 5 replies, has 3 voices. Last updated by  Cristián Lávaque 3 years, 4 months ago.

Topic Author Topic
Posted: Tuesday Aug 20th, 2013 at 11:08 am #56261

This is a question in response to an older topic posted here: http://www.s2member.com/forums/topic/populate-wordpress-user-details/. I’ve successfully implemented the recommendations in that topic to update the WordPress user_url field with a custom website field value.

However, on my site I’m also using BuddyPress and Simple Press. Both allow users to edit their profile – in particular user_url. I can’t and don’t want to restrict that. My questions is: how could I re-sync the custom website field with an updated user_url value? I am using [s2Member-Profile /] and have disabled access to the standard WP profile.

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Tuesday Aug 20th, 2013 at 6:33 pm #56288
Moderator
@Alternatewords

This will most likely require a custom filter applied to get_user_metadata

Something like this perhaps.

Please create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
(NOTE: these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins)
(See also: http://www.s2member.com/kb/hacking-s2member/)

<?php
add_filter('get_user_metadata', 's2_user_metadata', 10, 4);
function s2_user_metadata($current_filter_value, $user_id, $key, $single)
	{
		if(is_null($current_filter_value) && $key === 'user_url')
			$current_filter_value = get_user_field('user_url', $user_id);
		
		return $current_filter_value;
	}
Posted: Thursday Aug 22nd, 2013 at 5:21 am #56418

Thanks so much for the reply. Pardon my ignorance, I am not too familiar with custom filters and functions. Do I need to edit this code, i.e. replace $key with $blogurl, the custom field slug I am using? This would just filter the value but not actually update the WP blog_url field? Correct me if I am wrong.

Posted: Wednesday Aug 28th, 2013 at 7:12 am #58774

Do I need to edit this code, i.e. replace $key with $blogurl, the custom field slug I am using?

It looks like you’d need to edit it if the field’s key is not [hilite mono]user_url[/hilite], then you’d need to change it to the correct meta key.

This would just filter the value but not actually update the WP blog_url field?

That seems correct. The hack doesn’t seem to update anything in the database, and also, the meta key used is [hilite mono]user_url[/hilite], not [hilite mono]blog_url[/hilite].

Posted: Wednesday Aug 28th, 2013 at 7:57 am #58783

Thanks a lot for the reply. I’ve decided to go with a different option after all, one that is a bit less headache inducing for the admins.

Quick rundown: We’re using s2member, BuddyPress and Simple:Press (excellent forum plugin), each serving a particular purpose. However, all provide their own profiles. Unfortunately BP and s2m do not provide any (easy) option for pull additional standard WP fields like website and bio, which are important for us. S:P however does. In addition s2m custom fields are difficult to pull into S:P as they are stored in arrays (BP being even more of a pain since it’s using a whole different table). On the other hand S:P stores its custom fields as more standard entries. So the question was how to use a minimum of profiles (S:P’s being a must) offering a maximum of synchronization.

After lots of head scratching and research I came across a plugin called User Profiles Made Easy (http://plugins.themefluent.com/upme/). It’s highly configurable and capable of pulling meta data from any application (as long as it’s stored in usermeta). It’s extremely easy to use and highly intuitive. We now add custom fields via S:P and pull them in via UPME to present on a nicely styled profile in the frontend. In turn users can easily update their information via the UPME form, or via S:P when using the forum – and all data is kept nicely in sync. The BP profile is not used and kept hidden as much a possible. The s2member profile is, sadly, kept away as well.

All being said I’d much prefer using s2member’s profile option (considering registration and all) – if it would offer the same flexibility as UPME. That would make things even more seamless. Obviously it can be done.

Posted: Wednesday Aug 28th, 2013 at 8:46 am #58796

I’m glad you solved it! :)

And thanks for telling us about that plugin, I’ll show it to Jason.

Viewing 5 replies - 1 through 5 (of 5 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.