Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wpmudev-sls/6fe730321d3f74898c9849907d68e07c to your computer and use it in GitHub Desktop.
Save wpmudev-sls/6fe730321d3f74898c9849907d68e07c to your computer and use it in GitHub Desktop.
[Forminator] BuddyPress xprofile simple integration
<?php
/**
* Plugin Name: [Forminator] BuddyPress xprofile simple integration
* Plugin URI: https://wpmudev.com/
* Description: How to use it? Go to Your Form > User Registration > Custom User Meta > Add Custom User Meta and add/map your BP fields there with the "bpxprofile-" prefix (eg.: bpxprofile-Name).
* Author: Glauber Silva @ WPMUDEV
* Author URI: https://wpmudev.com/
* Task: SLS-3360
* License: GPLv2 or later
*
* @package Forminator_BuddyPress_Exprofile_Simple_Integration
*/
defined( 'ABSPATH' ) || exit;
function forminator_bp_xprofile_integration( $check, $user_id, $meta_key, $meta_value, $prev_value ){
if ( function_exists( 'xprofile_set_field_data' ) && false !== strpos( $meta_key, 'bpxprofile-') && empty( $prev_value ) ) {
$check = false;
$meta_key = str_replace( 'bpxprofile-', '', $meta_key );
xprofile_set_field_data( $meta_key, $user_id, $meta_value );
}
return $check;
}
add_filter( 'update_user_metadata', 'forminator_bp_xprofile_integration', 999, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment