Populate WordPress User Details

Hi All, I’m look for what I hope will be easy clarification on a previous topic, on the old forums.

I’m trying to get the wordpress user profile field “website” available for edit on the [s2Member-Profile /] page.

The original post I referenced: https://www.s2member.com/forums/topic/populate-wordpress-user-details/

Jason provided code to accomplish this
(https://www.s2member.com/forums/topic/populate-wordpress-user-details/index.html#post-17701):

All registration data ultimately is piped through s2Member’s core registration routines, located inside:
/s2member/includes/classes/registrations.inc.php

If you wanted to update meta values, based on GET/POST data; you might do it like this:

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
( these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins )


<?php
add_action('ws_plugin__s2member_after_configure_user_registration', 'my_registration_function');
function my_registration_function($vars = array())
{
	if($vars&#91;'processed'&#93; === 'yes')
		{
			$user = $vars&#91;'user'&#93;; // A WP_User object instance.
			update_user_option($user->ID, 'my_value', $_POST['my_value']);
		}
}

If you only want to run this for paying customers, you can change the hook in the code above, to:
ws_plugin__s2member_during_configure_user_registration_front_side_paid   

Raam provided a revised version of the code to connect directly (as I understand it) with and edit the WordPress User Details website field (https://www.s2member.com/forums/topic/populate-wordpress-user-details/index.html#post-17939):

Hi Pete,

There were a few problems with my code. Please try the updated version below:


<?php add_action('ws_plugin__s2member_after_handle_profile_modifications', 'update_user_url'); function update_user_url($vars = array()) { $user = $vars['user']; // A WP_User object instance. wp_update_user( array ('ID' => $user->ID, 'user_url' => $_POST['ws_plugin__s2member_profile_website']) ) ; } ?>

This code uses the wp_update_user() function instead of update_user_option(). Also note that s2Member dynamically adds the prefix ws_plugin__s2member_profile_ to the name of your custom registration field.

OK - So, here’s where I’m at:

  1. I created directory and file /wp-content/mu-plugins/s2-hacks.php
  2. I have a s2Member custom field to the Registration/Profile Field & Options:

Field Label: Dealer Website
Form Field Type: Text (single line)
Unique Field ID: dlr_website

I’ve attempted adding the php code that Raam and Jason provided to the s2-hacks.php file. I’ve tried the code as is, and revising the $_Post[], with my unique filed ID, using both $_POST['ws_plugin__s2member_profile_dlr_website'] and $_POST['dlr_website']

Neither have connected the custom field Dealer Website (unique field ID: dlr_website) with the WordPress user profile field “Website”.

What detail am I missing? I saw the original poster was able to make this work, so I figure I’m missing some detail that’s going to make me smack myself on the head.

Thanks!

Is there any reason to not use “custom profile fields”?

Thanks for responding Krumch. Our reasoning behind it boils down to exporting orders from woocommerce. Most of our buyers want to include their website on their order, and I thought having the custom profile field connect with the WordPress User Info Website field would resolve the export issue we’re facing. I’m continuing to search for a solution. But, when I found the original “Populate WordPress User Details” post that connected both the s2Member custom field with the WP User Info Website field, I thought I was golden. …Just was struggling to make it work. I was lost on what was missing, that the original poster made it work, but, it’s not working for me. Thanks.