Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add checkbox custom profile field data to directory with links


  • jonnyscholes
    Member

    @gogger

    Hey all,

    Iv searched high and low for an answer to this, and have come close a few times…. i think. Basically i want to include a checkbox profile field into the directory listings [users choose categories on registration], but the same way its displayed on the profile as links to the member search. Displaying them as just text is easy:

    bp_member_profile_data( ‘field=Catagories’ );

    But how would i either use xprofile_filter_link_profile_data to filter the data like it does on the profile, or load the output from bp_member_profile_data( ‘field=Catagories’ ); into an array so i can use a foreach loop to output them as desired. Im by no means an expert php programmer, but i know the basics. Iv tried using preg_split to put the output into an array using commas as the pattern to no avail, but even then surely theres a better way. Using the xprofile_filter_link_profile_data filter somehow id have thought.

    Before i get flamed, iv searched and searched both here and on a number of other WPMU/BP forums/support sites. Any help would be greatly appreciated :D

    Cheers,
    Gogger

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

  • jonnyscholes
    Member

    @gogger

    Got up this morning and tried a few other ideas. But none worked :(

    $usercatsraw = bp_member_profile_data( ‘field=Catagories’ );
    $usercats = explode(” ,”, $usercatsraw);
    foreach ($usercats as $value)
    {
    echo $value . “br tag”;
    }

    Returns the checkbox catagories in exactly the same way as bp_member_profile_data( ‘field=Catagories’ );

    .

    I tried this also, modified from another thread. It was old though…

    $field_value = bp_member_profile_data( ‘field=Catagories’ );
    echo xprofile_filter_link_profile_data( $field_value, $field_type = ‘checkbox’ );

    Crashes the entire feed. Anyone got any ideas?


    jonnyscholes
    Member

    @gogger

    Ok this is just weird. For the sake of trying to figure out what the hell is going wrong, i tried doing something very similar to this thread:

    https://buddypress.org/community/groups/creating-extending/forum/topic/providing-additional-info-in-userlist/

    Heres the working [according to the thread] code @DJPaul posted:

    function stwc_website_link() {
    $data = bp_get_member_profile_data( ‘field=Website’ );
    if ( $data )
    echo “Website: {$data}“;
    }
    add_action( ‘bp_directory_members_item’, ‘stwc_website_link’ );

    and heres my slightly modified version:

    function cat_links() {
    $data = bp_get_member_profile_data( ‘field=Catagories’ );
    if ( $data )
    echo “Website: {$data}“;
    }
    add_action( ‘bp_directory_members_item’, ‘cat_links’ );

    It /should/ output a link that has the normal category output as its title [eg. Animation, Pottery, Photography] and link to a href thats the same as the title [obviously it would get you to a page not found, but this is just for a test]. BUT it just outputs the categories in exactly the same way as bp_member_profile_data( ‘field=Catagories’ ); or bp_get_member_profile_data( ‘field=Catagories’ ); – no links, no span tags, no label saying “Website:”. This is rather confusing.


    jonnyscholes
    Member

    @gogger

    Bump? If anyone can come up with a method ill paypal/direct deposit them $20USD [not heaps i know, its all i can afford currently].

    Just gonna bump this again so its on the front page, getting to the second page seems to be broken currently…. having to find this post in my history or edit the url manually.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add checkbox custom profile field data to directory with links’ is closed to new replies.
Skip to toolbar