Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'hide xprofile fields'

Viewing 25 results - 26 through 50 (of 93 total)
  • Author
    Search Results
  • shanebp
    Moderator

    I wouldn’t rely on messing with visibility settings.
    To make a profile field only editable by admins, do this in bp-custom.php or a plugin:

    // only admins can edit the Skills field
    function chief_hide_profile_fields( $retval ) {
    	
    	if( is_super_admin () )
    		return $retval;
    
    	if(  bp_is_profile_edit() || bp_is_register_page() )
    		$retval['exclude_fields'] = '3';	//profile field ID's separated by comma
    
    	return $retval;
    
    }
    add_filter( 'bp_after_has_profile_parse_args', 'chief_hide_profile_fields' );

    Note that you need to add the correct id(s) for exclude_fields.
    And that ‘ || bp_is_register_page() ‘ keeps the field(s) off the register page – which you may not need to do.

    Re how to create profile fields in code, there a couple of ways to do it depending on the kind of field and how it will be used.
    Take a look at these plugins for more info:
    https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/
    https://wordpress.org/plugins/buddypress-xprofile-image-field/

    #188504
    danbp
    Participant

    Another snippet, more accurate with the suggested way above. Snippet goes into bp-custom or functions.php

    The field/field group is only shown to site admins. A small bug in the current BP version(.0 -> 2.0.2) prevent of completely remove the group tab from the edit screen. Bug is fixed and this will work with BP 2.1.

    function bpfr_hide_profile_field_group( $retval ) {
    	if ( bp_is_active( 'xprofile' ) ) :	
    	
    	// hide profile group/field to all except admin	
    	if ( !is_super_admin() ) {		
    		//exlude fields, separated by comma
    		$retval['exclude_fields'] = '60';  
    		//exlude groups, separated by comma - this may work with BP 2.1
    		$retval['exclude_groups'] = '7'; 			
    	} 
    	return $retval;		
    	
    	endif;
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
    #188500
    danbp
    Participant

    @csimpson,

    oh crossposting ! haven’t seen henry’s answer.

    nobody visibility doesn’t exist. This setting is called “only me“. This means that only the member can see this field – and the site admins. Such fields are not for site admins, but for the members !

    I don’t really understand what is not working for you, as what you’re looking for doesn’t exist in BuddyPress. Sorry if i’m misunderstanding you.

    When you create such a field visibility, you should also set “Enforce the default visibility for all members“, so the member cannot modify it later on his profile settings.

    Little weird side effect, when a “only me” field is used and member A wrote hello, this word becames clickabke, by default. When member B write also hello, it becames also clickable. And if A or B clcik on Hello, it shows a list of all members who wrote the same word. In this case A and B !

    Not really confidential, isn’t it ? The solution is to remove the clickable link.
    Here’s a snippet which let you do that selectively.

    function my_xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) {
        // Access the field you are going to display value.
        global $field;
    	
        // In this array you write the ids of the fields you want to hide the link.
        $excluded_field_ids = array(2,9,54); // field ID separated by comma
    	
        // If the id of this $field is in the array, we return the value only and not the link.
        if (in_array($field->id, $excluded_field_ids))
    	return $field_value;
    
    	if ( 'datebox' == $field_type )
    	return $field_value;
    	
    	if ( !strpos( $field_value, ',' ) && ( count( explode( ' ', $field_value ) ) > 5 ) )
    	return $field_value;
    	
    	$values = explode( ',', $field_value );
    
    	if ( !empty( $values ) ) {
    		foreach ( (array) $values as $value ) {
    			$value = trim( $value );
    			
    			// If the value is a URL, skip it and just make it clickable.
    			if ( preg_match( '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $value ) ) {
    				$new_values[] = make_clickable( $value );
    				
    				// Is not clickable
    			} else {
    				
    				// More than 5 spaces
    				if ( count( explode( ' ', $value ) ) > 5 ) {
    					$new_values[] = $value;
    					
    					// Less than 5 spaces
    				} else {
    					$search_url   = add_query_arg( array( 's' => urlencode( $value ) ), bp_get_members_directory_permalink() );
    					$new_values[] = '<a href="' . $search_url . '" rel="nofollow">' . $value . '</a>';
    				}
    			}
    		}
    		
    		$values = implode( ', ', $new_values );
    	}
    	
    	return $values;
    }
    
    /**
     * We remove the buddypress filter and add our custom filter.
     */
    function remove_xprofile_links() {
        // Remove the old filter.
        remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
        // Add your custom filter.
        add_filter( 'bp_get_the_profile_field_value', 'my_xprofile_filter_link_profile_data', 9, 2);
    }
    add_action('bp_setup_globals', 'remove_xprofile_links');
    mrapino
    Participant

    Okay, this is my first piece: http://pastebin.com/pyz8XaaP

    This first link is some code findings that might continue the conversation toward an elegant solution.

    And then I came up with another possible solution here, which is actually partially working, but might be a bit clunky: http://pastebin.com/3JBCuZrx

    Basically, the first link is not working, but may give us more food for thought. The second link is working, but there are a few caveats. What I am doing in the second link is finding out what user role the logged in user is attached to. Then I create a conditional that states that if the user is under a certain role, it hides the profile group tabs from being seen, which essentially prevent them from adding content to them, and if there is no content for any of the fields in the group, it won’t show on the front end.

    CAVEAT: if you go directly to the profile group URL, you can still edit. I need to figure out how to actually prevent the URL from working, as opposed to/ or in addition to hiding it.

    Either way, I think there’s a bunch of good stuff to talk about here.

    Let me know what you think.

    NOTE: I am using some code found on this post:
    https://buddypress.org/support/topic/conditional-exclusion-of-a-xprofile-fields-group-from-editing/

    #187041
    danbp
    Participant

    Would it matter that I have my group_order (i.e., the order in which my field groups are displayed) arranged in a specific order?

    No !
    Anyway, i was wrong myself. Apologize. My snippet hides groups from viewing, not from editing. But you can get another trick on this post. And this one works realy. 😉

    #186516
    danbp
    Participant

    Hi @simpleone,

    you can actually only hide xprofile fields. Hiding field groups is not possible, due to a bug.
    But it is corrected for 2.1 and you’ll find a patch on the trac.

    You can already apply the patch to 2.0.2 bp-xprofile-classes.php and the above snippet will work. Add it to bp-custom.php or theme’s functions.php

    To hide an xprofile group, use bp_parse_args like this:

    function bpfr_make_profile_tab_members_only( $retval ) {
    	// hide to non members
    	if( !is_user_logged_in() ) {
               // exlude groups, separated by comma
    		$retval['exclude_groups'] = '4,5';
               // exclude fields, separated by comma
           		$retval['exclude_fields'] = '1,39';			
    	} 
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_make_profile_tab_members_only' );
    #183740

    In reply to: Remove profile links

    CommonEasy
    Participant

    sorry to bump this old topic. I use both BP 2.0.1 and BP custom fields type and i got the the links removed with:

    function remove_xprofile_links() {
        remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
    }
    add_action('bp_setup_globals', 'remove_xprofile_links');

    I was wondering if you could use this to only hide the links from certain profile fields, like only for profile field 2, 6 & 7 ?

    #183705
    compixonline
    Participant

    Hi –

    I really appreciate your reply… it’s a little above my head but working on it. How would you then populate the buddypress Xprofile fields (which would be the same, say user_meta is occupation I would have a BP Xprofile field “occupation” and I’d want to copy it across.

    I’d also want to hide the ability to change that field in the BP members profile, forcing them to use the Membermouse field in order to change their occupation both in the Membermouse Table and their BP profile…

    Hope you can help! Many thanks.

    #183636
    Iurie Malai
    Participant

    @simpleone,

    Can you show how you solved your problem? danbp‘s code did not work for me. As you, I also wanted to hide some xprofile fields and tabs that I don’t want users to be able to edit.

    Iurie Malai
    Participant

    @danbp, I know how to check for errors, but this didn’t helped me too much :). I solved with the blank page, but no more. Your solution works for hiding some xProfile tabs from viewing, but not from editing them. Am I wrong? Sorry!

    This is my tested function (as I said, it hiding only from viewing, not from editing):

    
    function flegmatiq_profiles( $retval ) {
    
       if ( is_user_logged_in() && !bp_is_profile_edit() ) {
          $myfield = xprofile_get_field_data( 'User Type' );
          if( $myfield == "Faculty" ) {
             $retval['exclude_groups'] = '2';
    	 //$retval['exclude_fields'] = '6,18,39';
          }
       }
    
       return $retval;
    
    }
    
    add_filter( 'bp_after_has_profile_parse_args', 'flegmatiq_profiles' );
    

    The next code works as I need, but I think it is not so elegant, and it not allow to use the group ID, only his order number, as ordered by admin:

    
    function hide_profile_group_tabs_from_editing( $group_names ){
    
       if ( is_user_logged_in() && bp_is_profile_edit() && xprofile_get_field_data( "User Type") != "Faculty" ) {
          for ($x=0; $x<=sizeof($group_names); $x++) {
             if ( $x != 3 ) echo $group_names[$x]; //3 is the order number (from 0) of the tab that I need to hide in the profile edit page. This is not the group ID.
          }
       } else {
          return $group_names;
       }
    
    }
    
    add_filter('xprofile_filter_profile_group_tabs', 'hide_profile_group_tabs_from_editing');
    
    danbp
    Participant

    Since BP 2.0, you can use bp_parse_args to customise template loops and on a much easier way as never before.

    The example function below will hide profile groups with ID 1 and profile fields IDs 6, 18 & 39 on the public profile screen of each member and stay visible on the edit screen. Tested & approved 2.0.1

    If you get some php warning while using this function, be aware that there is a bug in 2.0.1 bp-xprofile-classes.php (fixed. See ticket). Simply apply the lattest patch to get rid of this error.

    function flegmatiq_profiles( $retval ) {	
       // conditionnals to set accordingly to your purpose
    	if( !is_user_logged_in()  && !bp_is_profile_edit() ) { 
    		$retval['exclude_groups'] = '2';	
    		$retval['exclude_fields'] = '6,18,39';	
    		
    	} 
    	return $retval;
    	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'flegmatiq_profiles' );

    In your particular case, you have to play with the conditionnals

    The example below is to give you an idea how to handle this. Not tested !

    function flegmatiq_profiles( $retval ) {
    $myfield = xprofile_get_field_data( 'Faculty', $user_id );
    if( empty( $myfield ) )
    return; // or echo
    
       if( $myfield == "Faculty" ) 
          if( bp_is_profile_edit() ) { 
    		$retval['exclude_groups'] = '1,56';	
    		$retval['exclude_fields'] = '6,18,39';	.
          }
       if $myfield == "field_name_2";
         // do something other...
    
    return $myfield;
    
    add_filter( 'bp_after_has_profile_parse_args', 'flegmatiq_profiles' );
    #183075
    danbp
    Participant

    Hi @SimpleOne,

    read from line 154 in bp-xprofile-classes.php file. It contains many information for what you want to do.
    See also on Codex here and here

    You can also revert your changes back and use this kind of function (goes into theme’s functions.php or bp-custom.php):

    function simple_one_hide_some_profile_fields( $retval ) {	
    	
    	if(  bp_is_profile_edit() ) {		
    		$retval['exclude_fields'] = '48';	//field ID's separated by comma
    		
    	}	
    	
    	return $retval;
    	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'simple_one_hide_some_profile_fields' );

    May this help ? 😉

    #181170
    serks
    Participant

    Hi have a very similar issue and I think it may be related to the same cause.

    I have set up a xprofile group where I have a bunch of different radio fields like so…

    About You Widget
    Show | Hide

    Display Avatar On Profile
    Show | Hide

    Subscribed Member Badge
    Show | Hide

    etc.

    I have put code all around my website to show or hide things according to a users settings and it all works as it should BUT, the only problem is that the settings don’t take effect until a user goes to edit the particular profile group and clicks the ‘Save Changes’ button.

    Even though the defaults are set as they should be initially, they do not actually work until the user saves them.

    Any help on this issue would be much appreciated.

    Thanks

    #176347
    Hugo Ashmore
    Participant

    You’re not attempting to hide anything, if you have created xprofile field groups other than the default ‘Base’ then anything in those groups for user profile input will not show on the standard BP registration form only on the users account profile screen. If you are following that principle and those fields are showing on the main registration form then something is going wrong and likely you have third party plugins at work?

    #175772
    Shmoo
    Participant

    It’s my theme and I code WordPress themes for like 5 years now but I don’t see myself as a Developer it’s more a hobby 🙂

    I’m solid at HTML-CSS and can read PHP when I see it happen but I can’t write PHP it out of the box.

    This error shows up when I try to hide a complete xProfile-group-ID or just an unique xProfile-field-ID from the loop.

    This is what I did.
    Inside: my-theme/buddypress/members/single/profile/profile-loop.php
    I found the start of the loop

    
    <?php if ( bp_has_profile() ) : ?>
    ....
    

    My first thought was, maybe there are default options here to control the output of which ID’s will be visible so I started the search how the bp_has_profile() was build and looked into plugins/buddypress/bp-xprofile/bp-xprofile-template.php and found this at line 150:

    
    ....
    
    $defaults = array(
    	'user_id'             => bp_displayed_user_id(),
    	'profile_group_id'    => false,
    	'hide_empty_groups'   => true,
    	'hide_empty_fields'   => $hide_empty_fields_default,
    	'fetch_fields'        => true,
    	'fetch_field_data'    => true,
    	'fetch_visibility_level' => $fetch_visibility_level_default,
    	'exclude_groups'      => false, // Comma-separated list of profile field group IDs to exclude
    	'exclude_fields'      => false  // Comma-separated list of profile field IDs to exclude
    );
    

    This looks very familiar to bbPress so my first thoughts was lets try to add one of those Array’s to the loop and overwrite the default value.
    Just like this.

    
    <?php if ( bp_has_profile( array ( 'exclude_groups' => 1 ) ) ) : ?>
    ...
    

    This works perfect, it hides all xProfile-fields from the first Base primary Tab (back-end). Just like I wanted it because I didn’t want all the fields to show up front-end, I’ve got a few xProfile-fields that I use for user-customization of the profile-page. Each user can add color-codes to change the default menu-color and add background-images to their profile-page to make each profile a little more unique.
    Those field-ID’s are just urls or color-codes and don’t have to be visable to the public, thats why I try to hide them front-end.

    buddypress member pofile tab

    #167792
    nobodymove
    Participant

    @bphelp. I think I have discovered the culprit to this little mystery.. I have been using the Buddypress Members Import plugin: http://www.youngtechleads.com/buddypress-members-import/

    For some reason when I import my database, the plugin does not seem to process the xProfile Field visibility settings properly.. The profile fields are still listed as “Admins Only” But for some reason they are still visible to all users.

    Earlier, I manually added some new test profile fields and they worked fine. I also discovered, that if I edit, and re-save a user’s profile field after import, all profile fields for that user will then revert to the proper visibility settings.

    I have contacted the plugin author to make him aware of the issue, hopefully he can fix it. If you have any suggestions that might be a quick fix for this I’m all ears! 🙂

    #167443
    nobodymove
    Participant

    Thanks @bphelp. Info listed below:

    1. Which version of WordPress are you running?

    3.5.2

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

    Directory

    3. If a directory install, is it in root or in a subdirectory?

    root

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

    3.5

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

    Wordpress seems to be working fine

    6. Which version of BP are you running?

    1.7.2

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

    1.7

    8. Do you have any plugins other than BuddyPress installed and activated? If so, which ones?

    Yes, a lot. 🙂

    Allow Multiple Accounts
    amr users + buddypress
    buddypress group email subscription
    buddypress member import
    buddypress message attachement
    Buddypress Toolbar
    Buddypress Xprofile custom fields type
    comprehensive google map
    contact form manager
    events manager pro
    easy table
    form lightbox
    GRAND Flash Album Gallery
    Lightbox Galleries EWSEL
    Mass Messaging in Buddypress
    Online Backup for WordPress
    Peter’s Login Redirect
    SHortcode Widget
    User Switching
    WP Full Calendar
    WP Wunderground

    9. Are you using the standard BuddyPress themes or customized themes?

    I’m using Razor 1.1.3 from Themeforest/Parallelus

    10. Have you modified the core files in any way?

    No

    11. Do you have any custom functions in bp-custom.php?

    No

    12. If running bbPress, which version? Or did your BuddyPress install come with a copy of bbPress built-in?

    13. Please provide a list of any errors in your server’s log files.

    14. Which company provides your hosting?

    Network Solutions

    15. Is your server running Windows, or if Linux; Apache, nginx or something else?

    VPS hosting package

    #144322
    David Cavins
    Keymaster

    I think a better bet is to collect that info on the BP registration page and then not display it on the user profile (that way you’ll still be able to use it in other ways). With BP 1.6. you can change the visibility of each xprofile field to friends only, logged-in users, or public (and force that level or allow the user to override your selection). (Visible to admin only is coming in BP 1.7, btw, which would totally fix you up.) At the moment, you can modify your theme template file (themes/yourtheme/members/single/profile/profile-loop.php) to hide some fields like this:
    `about line 17:

    <?php $no_display_fields = array( // Enter the field name of any field that you don't want to appear on the user profile.
    ‘E-mail’,
    ‘Name of Field Hide’,
    ‘Another’
    );

    if ( bp_field_has_data() && !in_array( bp_get_the_profile_field_name(), $no_display_fields ) ) : ?>`

    It’s a hack, but it works for me (until BP 1.7).

    #140405
    johndavis84
    Member

    I need to be able to show / Hide XProfile groups based on select value during the registration phase. I’m a newbie to all this so could someone please help on how accomplish this.

    Is that possible with buddypress? Has this plugin been created?

    Roger Coathup
    Participant

    @natetheaverage

    an outline solution (there are lots of areas where you’d have to work to implement it):

    When a group is created, you could write a hook that creates a corresponding xprofile field group (remember to hook on delete group as well to remove the profile field group)
    In the member’s profile screens, you would hide that xprofile field group if the member is not a member of the group
    In a hook on Join Group, you’d want to display an additional screen that prompts for the user fields, and when that is submitted use the xprofile API to write the data to the user’s profile
    I guess finally, you’d also want to modify the members loop inside the group to show that information

    There’s a lot of code for you to trawl through

    Hugo Ashmore
    Participant

    You’ll need to do something like wrap the custom xprofile loop section in a check for a specific field name ‘birthdate’ and do something like ‘if not’ ‘birthdate’ go ahead and display field item or display if is_admin if you want to be able to see users data as a site admin.

    To remove a field you could do:
    `

    <tr>

    `
    in the profile loop; equally if you wanted to remove a complete field group you can copy the approach seen in the file for ensuring that the base group is not shown `if ( 1 != bp_get_the_profile_group_id() ) ` adding an OR followed by a check on the group id to hide.

    #129738
    Hugo Ashmore
    Participant

    Profiles are by default public, you can also extend them by creating your own custom xprofile fields, these and any profile fields can be further modified if wished to show or hide some based on whether the displayed user is also the logged in user.

    #128706
    Marcella
    Participant

    Hey @davidveldt this should do it if you are using the default theme. Otherwise you should integrate as you see fit.

    theme/registration/register.php

    You can add any groups or fields as you require. The groups and fields here are arbitrary.

    ` ‘player’, 4 => ‘coach’, 5 =>’parent’, 6 => ‘instructor’); ?>

    $role) : ?>
    <div id="” class=”role-fields”>

    <label for="”>

    <textarea rows="5" cols="40" name="” id=””>

    <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="” />

    `

    Create some profile groups to cater for each role. You can find the group id within the BuddyPress admin… In the url bar or investigate your database.

    You should set-up the $roles array above to match your requirements.

    Within the loop you can show any fields you have created within that xprofile group. If you have a select box within that group you would add the following code as outlined in the bp-default register.php

    `

    <label for="”>

    <select name="” id=””>

    `

    Finally add the following jQuery where you house any other code of similar ilk.

    `
    jQuery(“.role-fields”).hide();
    $roles = jQuery(“#roles”);
    jQuery(“#field_2”).change(function()
    {
    $role = jQuery(this).val().toLowerCase();
    jQuery(“.role-fields”).hide();
    jQuery(“#” + $role).toggle();
    });
    `

    Here’s a pastebin for all that above. http://pastebin.com/QFdTdstz

    No need for tabs or accordion this time.

    Hope that helps you on the Road.

    #128632
    Marcella
    Participant

    Just an example here, running with Paul Gibbs start point.

    Create xprofile fields as normal.

    Each career group would also have its own xprofile group.

    Player would have his / her own set of fields.
    Coach would have his / her own set of fields.
    Parent would have his / her own set of fields.
    Instructor would have his / her own set of fields.

    None of the above would be required fields. (as far as BuddyPress is concerned (unless you roll some PHP codes))

    You’d have another xprofile group specifically for required fields (this would be your first group).

    You would make the “type” part of the required group and set it as a select box.

    You could then write your registration form mark-up matching the requirements of jQuery tabs or jQuery accordion.

    The “type” would be the last item on the required fields. Once that was selected you could then show or hide the corresponding jQuery ui-tab-panel that holds those form fields.

    You could then on-the-fly make those fields then required using some jQuery also but a bit hacky.

    #126155
    freque.unce
    Participant

    I changed register.php to display profile group 3 (optional profile fields I added via dash) instead of 1, to hide the required displayname option on signup, which forces it to clone username data by default. I then removed the ability to change names in xprofiles’ edit.php (with if/else, statements on textbox & submit button for profile group 1).

    Those 2 steps take care of all future occurances, so I then went in and changed all of my existing users’ display names to match their usernames, manually, via the dashboard.

    Problem solved. More of a substitute than a removal, but it works for me. Hopefully someone will find this useful.

Viewing 25 results - 26 through 50 (of 93 total)
Skip to toolbar