Im new with worpress.
I have a site wp+buddypress. Now i want get a fields value in user profile and do something depend by this field value. I can get this value useing:

$class = xprofile_get_field_data( ‘Field_Name’, $user_id );

But i can't found place where i gonna put my code.
What method i need to modify, or maybe exist hook what i can use to create separate plugin?

UPDATE Some code

function remove_xprofile_links() {  
    global $current_user;
    $user_id = $current_user->ID;
    $field = xprofile_get_field_data(3, $user_id);

    echo "<script>console.log( 'Debug Objects: " . $field . "' );</script>";
add_action( 'bp_init', 'remove_xprofile_links' );


I put some code in bp-custom.php. Now i know a field value. But still dont know how to hide fields. Any advises?

  • I would say it depend on what you want to do :-) – bestprogrammerintheworld Oct 4 '15 at 8:12
  • @bestprogrammerintheworld i want to hide profile fields depend this field value. – Kliver Max Oct 4 '15 at 8:14
  • The easiest way I think would be putting a function inside functions.php (preferably in a child theme) and calling that function from the template that are used. – bestprogrammerintheworld Oct 4 '15 at 8:18
  • I update question please look at it. – Kliver Max Oct 4 '15 at 8:27
  • Where do you want to hide fields? In the profile loop? – shanebp Oct 4 '15 at 15:12

I'm not sure I understand your question correctly, but I give it a try...

<?php function remove_xprofile_links() {  
    global $current_user;
    $user_id = $current_user->ID;
    $field = xprofile_get_field_data(3, $user_id);

    $class = 'normal-profile';
    if ($field == '{whatever}') {
        $class ='hidden-profile';

    $html = '<div class="' .$class . '">' . $field . '</div>';
    echo $html;

And in css you should have

.hidden-profile {display:none;}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.