Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get all values from a custom profile field

  • @sakyastelios

    Participant

    Greetings, how can I get all values from a custom profile field?
    I add a new custom profile field with the name “school name”. How can I get all values wrote by the users to display it in a selectbox?

Viewing 2 replies - 1 through 2 (of 2 total)
  • @shanebp

    Moderator

    You’ll need to use a custom query.
    Untested, try:

    global $wpdb;
    $field_id = 8; // change to the id of 'school name'.
    $query = "SELECT field_value FROM " . $wpdb->prefix . "bp_xprofile_data WHERE field_id = " . $field_id;
    $school_names = $wpdb->get_col( $query );

    $school_names will be an array.
    Loop thru it to create your dropdown.

    @sakyastelios

    Participant

    Many thanks, it results! You save my life

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get all values from a custom profile field’ is closed to new replies.
Skip to toolbar