Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide Profile Group When Editing


  • haughtam
    Participant

    @haughtam

    I can’t find the answer to this anywhere.  I have a profile group named “hidden” with xprofile fields that are used by me to track hidden information about users.  I can prevent this profile group from displaying while viewing the profile, but not while editing the profile.  In the members/single/edit.php file, there’s a function bp_profile_group_tabs() that displays the profile group buttons.  Does anyone know how I hide one of those?

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

  • juanmaguerrero
    Participant

    @juanmaguerrero

    Do ypu want to hide it via CSS or only trough PHP?


    shanebp
    Moderator

    @shanebp

    re the php approach:
    Do you know how to use apply_filters ?
    If so, see this:

    `
    $tabs = apply_filters( ‘xprofile_filter_profile_group_tabs’, $tabs, $groups, $group_name );`

    in bp_profile_group_tabs() in /bp-xprofile/ -> bp-xprofile-template.php


    haughtam
    Participant

    @haughtam

    It’s been a while since my original post, but I think I’ve figured this out and I hope this helps someone else.  The original problem changed a bit too.  Basically, now I want to show a profile group based on the value in an xprofile field (when editing a profile).  So, if my User Category field for a logged in user says Recruiter, then I want to show the profile group called “Recruiter” (show this for admins too).  Otherwise, I want to hide this profile group through php.

    Thanks to the hint above, I was able to come up with a function in my child theme’s function.php file.

    I’m just learning php/wordpress, and I don’t have a clear understanding why this works.  I do know that $group_name[3] is the Recruiter profile group.  Also, I do realize this snippet uses awful coding practices.  If anyone has improvements, please let me know.

    function my_recruit($group_name){

    if ( is_site_admin() || xprofile_get_field_data( “User Category”)===”Recruiter”) {

    echo $group_name[0];

    echo $group_name[1];

    echo $group_name[2];

    echo $group_name[3];

    }

    else {

    echo $group_name[0];

    echo $group_name[1];

    echo $group_name[2];

    }

    }

    add_filter(‘xprofile_filter_profile_group_tabs’,’my_recruit’);


    cyndimarie
    Participant

    @cyndimarie

    @haughtam Sort of off topic, but how did you hide the profile group when it’s being viewed? I have a profile group that I want to be shown when editing, but hidden when viewed (because the info is being called elsewhere). Thanks!


    olumi_day
    Participant

    @olumi_day

    @haughtam just wanted to say thanks for that little bit of code up there.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hide Profile Group When Editing’ is closed to new replies.
Skip to toolbar