Skip to:
Content
Pages
Categories
Search
Top
Bottom

get buddypress profile field value!

  • Hello,
    I’m using wordpress with buddypress.
    What I want is to get the value of a specified profile field of buddypress for each logged user to replace it in a link i have in one of my pages.

    to explain more what i have done is for a university. each student has one class code. i have made a field to let them write their class code.

    it is like “sc10002” for example.

    what i want is to replace this “sc10002” in a link which send them to their class time schedule which is like:

    hxxp://university.com/shchedule.jsp?[classid]

    how can i do it? i mean how can i order this link to replace class id with what has been set in student profile?

    i’d appropriate your help.
    thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

  • r-a-y
    Keymaster

    @r-a-y

    The function you’re looking for is:
    `bp_get_profile_field_data()`

    An example use case:

    `
    $field = bp_get_profile_field_data(
    array(
    ‘field’ => 1, // where 1 is the field_id or it can be the field name
    ‘user_id’ => bp_displayed_user_id()
    )
    );

    echo ‘Schedule link‘;`


    lexpression
    Member

    @lexpression

    Hello my fellow BP’ers. This is NOT working for me. It returns nothing…as if the field did exist. Any ideas?

    You could try this instead:

    Code:
    global $current_user;
    get_currentuserinfo();
    $user_id = $current_user->ID;
    $field = xprofile_get_field_data(1, $user_id); //where 1 is the field_id or use quotes for a field name and the user_id is the currently logged in user
    echo ‘<a href="hxxp://somedomain.com/something.jsp?’ . $field . ‘">Your Text</a>’;
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get buddypress profile field value!’ is closed to new replies.
Skip to toolbar