We’re using s2member on our eclass site for which I created a single custom profile field called ‘Blog URL’ in addition to the standard WP website field (user_url). Would it be possible to pull this field on to the SP profile so that students could edit it from there as well? It’s a matter of keeping things in sync across their s2 member profile and SP profile.
Support Forum
Do you know where s2member stores this data? If it sticks rigidly to the WP API then it should store it in the usermeta table. And if it does that – and you do really need to check – then use our Custom profile fields plugin to create the SAME field and make sure the name is identical. Actually t is not the name it is the slug – make sure that you name it using the slug that s2member created.
If this woks then your data will be pulled into SP although you will have to add the field to the profile form if you want iti there. which is covered in the codex article for the custom fields plugin.
Thanks so much for the quick response. I had a look at the backend. While s2mmeber does store it’s custom fields in usermeta it does so as an array, unfortunately. It’s meta_key value is simply wp_s2member_custom_fields and then an array of all custom fields stored in meta_value. I think this option is not going to work.
What a horrible and very non-standard thing to do.
OK never fear – there is another way.
Do you know how to code WordPress filters? – I.e., Apply_filter and add_filter calls?
I am not too familiar with WordPress filters (i.e. haven’t used them) but I am sure I can figure things out with a few tips in the right direction.
OK – there are two parts to this and tonight I am just going to cover part 1 which is getting your sp2member data into the Simple:Press user object. I have not tried this but it should work…
Open up the spFunctions.php file of your Simple:Press theme (in the theme /templates folder) so you can make an edit. You can actually use the built in theme editor for this in the SP themes section of the admin.
At the bottom of the file – but before the closing php tag of course, copy and then paste in this code:
add_filter(‘sph_user_class_meta’, ‘add_my_field’);
function add_my_field($list) {
$list[‘wp_s2member_custom_fields’] = ”;
return $list;
}
first thing after you save this is to run a forum page to make sure you have got it all right!
Then next – go to the forum admin > Toolbox > Data Inspector and turn on the option to see ‘spThisUser’. Next time you run a forum page you will see the SP user data object. You will be the only user to see it. Look down for the values of the custom fields to see if they have been included. They should be pretty near the top after the initial list of items.
Thank you so much. So far so good, the s2member custom fields are included (I’ve added a second one in the meantime for additional testing):
[wp_s2member_custom_fields] => Array ( [blog_category] => Personal Blog [blogurl] => http://cognizantdreamer.com )<br /><br />
Well – in the same /templates folder you will find two profile templates – one for the popup profile view and another when the profile is used as a page. You will only be using one of them.
If you take a few minutes to just scan through it you will see all the fields that are displayed on the popup or page – in sequence. So the first thing is to decide where you want to display your custom data. And the try to echo it out like this:
echo $spProfileUser->wp_s2member_custom_fields['blogurl'];
Of course you will probably want to style it and maybe show it in two columns like the current display and we can do that. First thing is to make sure it is working.
Added it to profile popup for testing – working perfectly well. Looking good so far.
The awesome power of WordPress filters and the beauty of template driven displays. Now one last thing…
As always we recommend that you create your own SP theme so that any customisation is not lost during a future update. (http://codex.simple-press.com/codex/themes/theme-basics/creating-a-theme/)
Done that as well. Now to figure out how to style it properly to say Blog URL and be clickable… (and editable in the SP profile).
I’m assuming the chances of s2member and S:P exchanging custom fields in the future is slim to none? That said, s2member does connect straight into BuddyPress and syncs custom fields, so there is a possibility.
I don’t know if you could trade bringing it in from S2Member to bringing it in from BuddyPress as I am sure BuddyPress DO adhere to the WP API in this respect.
We could probably make the s2member connection smoother with a small SP plugin of course.
You know it might be worth asking the s2member team if they would consider changing their custom fields and bringing them into line with the standard…
I could most certainly trade bringing it all in from BuddyPress. But s2member doesn’t actually create BuddyPress custom fields, they simply push their own custom fields on to the BuddyPress profile (there are options that can be enabled under s2member). And of course BuddyPress custom profile fields are not pulled onto s2member profiles… I’ll post on the s2member forum suggesting a bit more of a standard custom field handling.
In any case, a small SP plugin for a smoother connection sounds very interesting.
we do the same with our buddypress plugin… make some of our profile fields and options available on the buddypress edit profile form…
Good to know. I am actually using the buddypress plugin and have all options activated but am not seeing any SP fields appearing on the BP profile. I also couldn’t find a codex entry on usage of that plugin. Perhaps it’s colliding somewhere on the way with s2member. I can open a new topic for this if it makes sense.
Anyway, I am slowly getting somewhere. I posted on the s2member support forum, which isn’t quite as helpful as they don’t have a paid support system (they like to refer to outside coders for paid customization). But I got a function out of them to update WP blog_url whenever a users updates the custom blogurl field on their s2member profile. Now to go the reverse and sync blogurl with an updated user_url when changing so under the SP profile. I got a filter function from them but that doesn’t help me much. I posted again and hope to get a bit further. BUT if there anything from an SP side I could implement instead I would certainly not mind that either.