Support

Home Forums Event Espresso Premium WP User Intergation with User Profile for addresses (2)

WP User Intergation with User Profile for addresses (2)

Posted: August 5, 2014 at 8:36 am

Viewing 11 reply threads


Sidney Harrell

August 5, 2014 at 11:13 am

Hi Ben,
You should use a blank plugin to add custom functions. I explain it in some depth here: http://youtu.be/pqe1RQ4peAM. It may be focused on EE4, but it applies for anyone who wants to add custom functions to WP.


Ben

August 6, 2014 at 11:55 am

Thanks Sidney,

Great video on how to create a custom function as a plugin, makes more sense too rather than being in the child theme.

So I’ve created the custom.php file, put the code in, saved it, then compressed as a .zip file, and uploaded it as a plugin. Can’t see it working as of yet.

During the registration page here- http://screencast.com/t/ij6sWoyzc3i
Will I need another custom function to pull the details from the 3rd party to add at registration stage?
Is this the function to use – ‘action_hook_espresso_update_event_meta’ ?

Thanks.


Sidney Harrell

August 6, 2014 at 1:33 pm

Did you activate the custom functions plugin? Usually it’s easier to have it set up and activated, then add the code you want over ftp.
The EE wp-user add-on should autofill those fields in the registration form if it finds those metadata fields.


Ben

August 6, 2014 at 1:45 pm

Thanks Sidney,

Yes, the plugin is activated.
The EE wp-user add-on is activated, but the issue seems to have been that the data in the user profile is not populated, because the 3rd party ‘Paid Membership Pro’ has created another set of address data fields that are captured under ‘Shipping’. Basically their postal address to send something to, if need be.
Because the address data is in a new section in the User profile it has become apparent that’s why the EE add on will not pull the data through, I believe.
Consequently, this is why a custom plugin to pull the data from the 3rd party address fields, and mirror it into the EE address fields, is now what needs to be achieved.

Does that seem right to you?


Sidney Harrell

August 6, 2014 at 6:13 pm

So is the code that you posted above not putting the user meta data field ‘event_espresso_address’ in? Can you check the wp_usermeta table directly?


Ben

August 7, 2014 at 5:31 am

Yes Sidney, I’ve got access to the wp_usermeta table, and I’ve had a look where the 3rd party data is kept, which is present with the correct request code – http://screencast.com/t/A7ObBuOgJnN8

Is there something else we need to look at?
Thanks.


Sidney Harrell

August 7, 2014 at 11:29 am

But is there an entry for ‘event_espresso_address’? If there is not, then your custom script above is not copying the data to the right place.
You might want to run a one-time sql query to copy all the existing data (ie, saddress) to the ee fields for the same user.


Ben

August 12, 2014 at 10:13 am

Thanks Sidney,

These are all the fields available in the table for some users. These fields do vary, with Event Espresso appearing sometimes, and other times not, but I think that also goes for the other fields appearing, or not.

first_name
last_name
nickname
description
rich_editing
comment_shortcuts
admin_color
use_ssl
show_admin_bar_front
wp_capabilities
wp_user_level
dismissed_wp_pointers
home_phone
work_phone
mobile_phone
county
business_name
local_association
beekeeping_classification
directory
newsletter_preference
member_com_pref_1
member_com_pref_2
member_com_pref_3
spouse_first_name
spouse_last_name
pmpro_saddress1
pmpro_scity
pmpro_sstate
pmpro_szipcode
event_espresso_address
event_espresso_address2
event_espresso_city
event_espresso_state
event_espresso_zip
event_espresso_country
event_espresso_phone
wpseo_title
wpseo_metadesc
wpseo_metakey
_yoast_wpseo_profile_updated
billing_first_name
billing_last_name
billing_company
billing_address_1
billing_address_2
billing_city
billing_postcode
billing_state
billing_country
billing_phone
billing_email
shipping_first_name
shipping_last_name
shipping_company
shipping_address_1
shipping_address_2
shipping_city
shipping_postcode
shipping_state
shipping_country
googleplus
twitter
facebook

After discussing this with PMPro, they’ve now suggested to use the ‘pmpro_baddress1’ usermeta, as per below.

Here is the plugin code so far, which doesn’t seem to be working.

<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
function pmprowoo_update_user_meta($meta_id, $object_id, $meta_key, $meta_value)
{
//tracks updates that are made
global $pmprowoo_updated_user_meta;
if(empty($pmprowoo_updated_user_meta))
$pmprowoo_updated_user_meta = array();
if(empty($pmprowoo_updated_user_meta[$object_id]))
$pmprowoo_updated_user_meta[$object_id] = array();
//array of user meta to mirror
$um = array(
"event_espresso_address" => "pmpro_baddress1",
"event_espresso_address2" => "pmpro_baddress2",
"event_espresso_city" => "pmpro_bcity",
"event_espresso_zip" => "pmpro_bzipcode",
"event_espresso_state" => "pmpro_bstate",
"pmpro_baddress1" => "event_espresso_address",
"pmpro_baddress2" => "event_espresso_address2",
"pmpro_bcity" => "event_espresso_city",
"pmpro_bzipcode" => "event_espresso_zip",
"pmpro_bstate" => "event_espresso_state"
);
//check if this user meta is to be mirrored
foreach($um as $left => $right)
{
if($meta_key == $left && !in_array($left, $pmprowoo_updated_user_meta[$object_id]))
{
$pmprowoo_updated_user_meta[$object_id][] = $left;
update_user_meta($object_id, $right, $meta_value);
}
}
}
add_action('update_user_meta', 'pmprowoo_update_user_meta', 10, 4);
//need to add the meta_id for add filter
function pmprowoo_add_user_meta($object_id, $meta_key, $meta_value)
{
pmprowoo_update_user_meta(NULL, $object_id, $meta_key, $meta_value);
}
add_action('add_user_meta', 'pmprowoo_add_user_meta', 10, 3);
/*


Sidney Harrell

August 12, 2014 at 4:56 pm

Try the pmprowoo_update_user_meta function like this:
http://pastebin.com/apUvmfSL


Sidney Harrell

August 12, 2014 at 4:57 pm

woops, left my debugging code in there, try this one:
http://pastebin.com/ntSEJMuT


Ben

August 22, 2014 at 10:35 am

Thanks Sidney,

Just to provide a short update that the other 3rd party PMPRO Membership had a few bugs in it, which is what the support at PMPRO have been looking into. I still don’t have it finalised yet with them, but I will provide another update here with the code to share with you in the coming week.

Thanks.

Viewing 11 reply threads

The support post ‘WP User Intergation with User Profile for addresses (2)’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso