Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 1 replies (of 1 total)
  • @zoleest

    Participant

    Still not worked, but I found out a not too elegant solution. As far as I understand there is an order how the hooks run. There is a hook in class-buddypress.php add_action( 'bp_core_signup_user', array( $this, 'subscribe_from_form' ), 10, 4 ); so I added to my hooks 11, 4 so this is my code now:

    function xprofile_sync_wp_profile2( $user_id = 0 ) {	
    	
    	
    	
    	// Bail if profile syncing is disabled
    	if ( bp_disable_profile_sync() ) {
    		return true;
    	}
    
    	if ( empty( $user_id ) ) {
    		$user_id = bp_loggedin_user_id();
    	}
    
    	if ( empty( $user_id ) ) {
    		return false;
    	}
        
        global $wpdb;
    	
        // Get name from x-fields
        $display_name = xprofile_get_field_data('Név',$user_id );
        
    
        $wpdb->query( $wpdb->prepare( "UPDATE wphu_users SET display_name = '%s' WHERE ID = %d", $display_name,  $user_id ) );
    	
    	
    }
    add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile2', 11, 4);
    add_action( 'bp_core_signup_user',      'xprofile_sync_wp_profile2', 11, 4);
    add_action( 'bp_core_activated_user',   'xprofile_sync_wp_profile2', 11, 4);

    And fortunately it works now 🙂 I don’t know if this is a correct way, but work, so I’m okay with it.

Viewing 1 replies (of 1 total)
Skip to toolbar