Sending custom data to XenForo user profile fields
A look into syncing custom Custom user fields back to XenForo profiles…
XFtoWP offers a simple connection point to map custom user fields you wish to send from a WordPress user during actions and other syncing events.
Simply add the user fields and match the Field ID (see below) with the Field ID back on the XenForo side to connect across sites.

You should note that the “Random number field” choice is not included as a stock option, but left in there to show you how to add your own custom logic to custom user fields.
(Heads up, you’re about to get a high-dose piece of code)
From your theme’s functions.php file, or other place you run custom functions, use these two XFtoWP filters to plug your own logic into custom fields, with full use of WP user data at the time of any action or user sync:
PHP:
/**
* 1. Register field to XFtoWP + adds to Custom fields select box
*
* Set 'random_number' and text label as your own key
*/
function add_xftowp_custom_user_fields( $custom_fields ) {
$custom_fields['user']['random_number'] = array(
'label' => 'Random number field'
);
return $custom_fields;
}
add_filter( 'xfwp_custom_fields', 'add_xftowp_custom_user_fields' );
/**
* 2. Calculate logic to use as custom field
*
* Key name(s) must match as set in step 1.
* Insert your own logic into custom user fields at time of sync + other actions
*/
function xftowp_custom_user_fields_calculate( $custom_fields, $wp_user, $wp_usermeta, $post_id ) {
$custom_fields['random_number'] = rand();
return $custom_fields;
}
add_filter( 'xfwp_custom_user_fields_data', 'xftowp_custom_user_fields_calculate', 10, 4 );
When all is synced and done you can see the final results back at the XF user’s profile:

You know how to setup Custom user fields in XenForo, right?

If you’re the kind of person that knows what to do with this, let you creativity be unleashed.