Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profile Field Not Fetching?


  • oguruma
    Participant

    @oguruma

    I know very little about PHP, so stick with me

    I am using the Mautic (sort of like an open source Mailchimp) plugin to pass some user info to my Mautic instance.

    Essentially, I need to set a variable based on the users Phone number to give it to Mautic. I created a BP profile field called Phone. It simply updates the users phone number (in Mautic) to null, however.

    The code I am using is below. I know that the Mautic part of the code is right, because I previously used it with the UsersWP plugin, and it passed the right phone number. Any idea why the logic below isn’t passing the right Phone number?

    add_filter('wpmautic_tracking_attributes', function(array $attributes) {
        
    
    $bpphone = bp_profile_field_data( 'field=Phone' );
    $attributes['phone'] = $bpphone;
    
        return $attributes;
    });
Viewing 1 replies (of 1 total)

  • shanebp
    Moderator

    @shanebp

    bp_profile_field_data requires that is be used in the context of a member profile or the member loop.

    For other cases, use xprofile_get_field_data and note that you need to pass in the user id.
    For example, something like:

    $user_id = get_current_user_id();
    $bpphone = xprofile_get_field_data('Phone', $user_id, 'comma');

    xprofile_get_field_data

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar