Skip to:
Content
Pages
Categories
Search
Top
Bottom

Links in members-loop for Profile Field


  • israel4lincelot
    Participant

    @israel4lincelot

    Hi,

    I’m rephrasing my question for a better result:

    I would like my Profile Field Expertise to be shown as links on my members-loop.php:
    members-loop screenshot

    Exactly as it’s shown on the Profile page: Profile Loop Screenshot

    The line I’m using on members-loop.php is <?php bp_member_profile_data( 'field=Expertise' ); ?> but this outputs my Expertise field only as a paragraph.

    Thx!

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

  • Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    May I know which theme you are using and is it a BuddyPress theme?

    How you are entering expertise there? Is it any CPT or anything that you just have to select?

    Also if can send a screencast will be better to explain.

    I did a test but I put my value in anchor tag so it is coming a s a link everywhere. Please see: https://screencast-o-matic.com/watch/cF6jbAYFaL

    But I think in your case situation is different. Please answer all and let’s debug it.

    Thanks


    israel4lincelot
    Participant

    @israel4lincelot

    Hi Prashant, I should have maybe started with listing following information:

    1. Which version of WordPress are you running?
    WordPress 4.9.8

    2. Did you install WordPress as a directory or subdomain install?
    Subdomain

    4. Did you upgrade from a previous version of WordPress? If so, from which version?
    I installed the latest.

    5. Was WordPress functioning properly before installing/upgrading BuddyPress (BP)? e.g. permalinks, creating a new post, commenting.
    Yes

    6. Which version of BP are you running?
    Latest Version 3.2.0

    7. Did you upgraded from a previous version of BP? If so, from which version?
    No

    8. Do you have any plugins other than BuddyPress installed and activated? If so, which ones?
    BuddyDrive, Custom Profile Filters for BuddyPress, Gravity Forms, K Elements, Really Simple SSL, rtMedia for WordPress, BuddyPress and bbPress, Slider Revolution, What The File,
    WPBakery Page Builder

    9. Are you using the standard WordPress theme or customized theme?
    Customized.

    10. Which theme do you use ?
    Kleo Theme from seventhqueen

    11. Have you modified the core files in any way?
    Yes I have, but always in the child-theme.

    12. Do you have any custom functions in bp-custom.php?
    Yes
    <?php
    // hacks and mods will go here
    define( 'BP_DEFAULT_COMPONENT', 'profile' );

    ?>

    15. Which company provides your hosting?
    Compbell

    So to answer your other questions, I added a new Profile Field with checkboxes. Indeed you have to select it and that’s why I can’t just wrap it in an anchor tag because I need the fields to be clickable separately.

    In Profile fields the Expertises are individually links. In my Members page all the Expertises ar put in a Paragraph. But I’d like them to be individual links such as in Profile page.

    See Screencast here: https://screencast-o-matic.com/watch/cF6QiCYqw6

    Thx!


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    I found that those links are generated from the plugin Custom Profile Filters For BuddyPress and it only works on profile. So to get the same data with the link on members-loop.php we need to print fields like this:

    $data = bp_get_member_profile_data( 'field=Expertise' ); 
    echo '<a href="' . bp_get_members_directory_permalink() . '?s='.$data.'">'.$data.'</a>';

    Hopefully, this will help you.

    Thanks


    israel4lincelot
    Participant

    @israel4lincelot

    Hi,

    Yes this gives a Link but it wraps all the data in 1 link. I need them to be SEPARATELY so people can search individually. For example a person has 4 Expertises like; API planning, APO, Product launching, Product transfer. I want them to be able to click on “API planning” or “APO”. This because other people with the same expertise, for example “APO”, wil be listed. Many people have many Expertise and they are separated with a comma (,).

    Maybe this can be made possible by splitting the &data when there’s a comma. I think it’s also important to add “+” where theres a space for the URL Link to work, for example “API planning” should be “API+planning” on the URL link.

    Thx!


    israel4lincelot
    Participant

    @israel4lincelot

    Hi Prashant,

    So got it to work as follow:


    <?php $data = bp_get_member_profile_data( 'field=Expertise' ); ?>

    <?php $exp = array_map('trim',array_filter(explode(',',$data))); ?>

    <?php for ($x = 0; $x < count($exp); $x++ ) : ?>

    <?php echo ''.$exp[$x].''; ?> ,

    <?php endfor;?>

    Your code did help so thank you very much!

    Greetz!


    Prashant Singh
    Participant

    @prashantvatsh

    Glad to know that it helped 🙂

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