Created
March 15, 2022 14:21
-
-
Save wpmudev-sls/6fe730321d3f74898c9849907d68e07c to your computer and use it in GitHub Desktop.
[Forminator] BuddyPress xprofile simple integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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