Search Results for 'hide xprofile fields'
-
AuthorSearch Results
-
February 9, 2016 at 8:42 pm #249689
In reply to: How To Get Plaintext Multiline Field?
calvinParticipantAfter adding the fields you want using xprofile, go to your regi page. If you are using google chrome, right click on the multiline box and inspect
you should find out the the id of the visual/text box something similar this ‘wp-field_664-editor-tools’ (yours should be a bit different cos field number is different)
you should also find out the id of the mce panel using the same method
After that you should be able to add the custom css to your theme stylesheet.
Example (hiding the item using css):
#wp-field_664-editor-tools {display:none;}You may need to double check on the edit profile page. if it still appears there, you can use the same method to hide it.
Hope this helps.November 9, 2015 at 8:52 am #246500In reply to: [Resolved] Text Boxes Creating Unwanted Random Links
danbpParticipantHi @ma3ry,
unable to visit the indicated page due to redirection… BP’s xProfile text box contains are autolinked by default for the 5 first words.
This is handy when you use a field called city for example. The city name is autolinked and let each user click on it to find other who may entered the same name.Of course, an about me box with a long description, which several autolinked words has less interrest. Fortunately, you can deactivate xprofile autolinking.
Two options for this: all or selected.Here 3 snippets. The first can be used if you want to completely remove autolink from all field values.
The second is a new filter to let you choose the field(s) you want to deactivate. This need two snippet. The first to rewrite a filter and the second to remove / replace the existing BP filter.Add the snippet to bp-custom.php.
// remove any autolink from profile function remove_xprofile_links() { remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 ); } add_action( 'bp_init', 'remove_xprofile_links' ); // custom filter to selectively remove autolink 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 (separated by comma) of the fields you want to hide the link. $excluded_field_ids = array(2); // 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');
April 20, 2015 at 9:58 pm #238134In reply to: Links in Bio of Profile fields (Bug)
danbpParticipanthi @utahman1971,
this is the default behave of extended profile fields. Also it’s very handy, as those links became searcheable keywords. This let users click and find other entered same words.
That said, a bio is generally more personnal, so those links maybe less important…
Here’s a snippet (bp 2.0.1 +) you can add to bp-custom.php. It let’s you selectively disable those automated linking from some fields and let some other in place.
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,6,7); // 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');
If you want to deactivate completely profile fied links, you can use this function:
function bpfr_remove_xprofile_links() { remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 ); } add_action('bp_setup_globals', 'bpfr_remove_xprofile_links');
April 3, 2015 at 1:33 pm #237244danbpParticipanthi @mcpeanut,
this snippet useable from BP 2.0.1 and above, can be added to bp-custom.php
it will hide the field ID 1 which is the default Name field to all, except site admin.it will also avoid the user to edit that field. So if you use this, i recommand you tell them on register page that once they entered a name it they could change it later. You can than ask them $$$$ to do it. π
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'] = '1'; //exlude field groups, separated by comma $retval['exclude_groups'] = '1'; } return $retval; endif; } add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
More here:
December 17, 2014 at 6:56 pm #230724In reply to: [Resolved] Hide possibility to change 'Base' name
danbpParticipantSorry to answer you with a big laught, it’s not html but php. π
You should also find the time to read more attentively the forum, or search by keywords.
in this case: hide xprofile fieldshttps://buddypress.org/support/search/hide+xprofile+fields/
You’re welcome. Glad you got it. π
December 17, 2014 at 6:20 pm #230718In reply to: [Resolved] Hide possibility to change 'Base' name
danbpParticipantWhen BP is installed and xProfile is activated, the original WP profile settings are not accessible to user.
The WP register process use only username, password and email and BuddyPress add by default a Name field as base for other extended profile fields.
In short this means that username and name fields can contain a same information(a name, a pseudonym, a first or/and a last name). The plugin you mention is best for a WP install where user had choosen first/last name as output on post, comments, etc Once BP is activated, this became a little different.
Now to the initial question.
The CSS trick is a very inelegant solution as it lets everybody knowing how BP works to surround this invisibility. You’re also loosing any flexibility if you want to show some fields privately for example.You can do this properly with a little snippet, as explained here:
Here’s an example which let you hide fields or fiels group to members, but not to site admin
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'] = '1'; //exlude groups, separated by comma $retval['exclude_groups'] = '1'; } return $retval; endif; } add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
Add it to bp-custom.php or your child-theme functions.php
Of course you can also choose to show a field or group, but remove the possibility for the user to edit it later. Simply add more conditionnal to the function.
Here another example:
function bpfr_hide_profile_edit( $retval ) { // remove field from edit tab if( bp_is_user_profile_edit() ) { $retval['exclude_fields'] = '54'; // ID's separated by comma } // allow field on register page if ( bp_is_register_page() ) { $retval['include_fields'] = '54'; // ID's separated by comma } // hide the field on profile view tab if ( $data = bp_get_profile_field_data( 'field=54' ) ) : $retval['exclude_fields'] = '54'; // ID's separated by comma endif; return $retval; } add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_edit' );
Hope to be clear.
October 26, 2014 at 11:14 am #227729In reply to: Separate Business User
Henry WrightModerator- Have you searched the plugin directory?
- This can be done via hooks. It will need some custom code (not much, just a few lines).
- You could hide or show xProfile fields according to role. How exactly roles are created and managed will be dependent on point 1
- Again, to distinguish business users from ‘normal’ users, you’d use the roles created via the plugin you’re using from point 1. The jobs and adverts could each have their own custom post type
- This will need to be custom coded
Hope that helps?
October 11, 2014 at 1:35 pm #2100111a-spielwieseParticipantThe problems are still unresolved:
++ Cfr. regarding problem A. (Making xProfile fields required only for members with a certain user role):
https://wordpress.org/support/topic/making-bp-xprofile-fields-required-for-certain-user (posted today)
++ Hide theses xProfile fields for members with other user roles:
https://wordpress.org/support/topic/bb-xprofiles-acl-does-not-work (posted one week ago)
++ Cfr. regarding problem D. (Making answers unchangeable):
https://buddypress.org/support/topic/how-to-make-some-xprofile-field-to-uneditable/#post-206808 (posted two days ago).
October 8, 2014 at 1:03 pm #2062841a-spielwieseParticipantFor me also not:
I tried it with
Mitglieder-Kategorie (Team oder Fan?)
instead of
'name of your field'
as well as with
'Mitglieder-Kategorie (Team oder Fan?)'
But my users can still change the values for this field. –
I tried as well – already before and now again – this code of @noizeburger:
//hide the user role select field in edit-screen to prevent changes after registration add_filter("xprofile_group_fields","bpdev_filter_profile_fields_by_usertype",10,2); function bpdev_filter_profile_fields_by_usertype($fields,$group_id){ //only disable these fields on edit page if(!bp_is_profile_edit()) return $fields; //please change it with the name of fields you don't want to allow editing $field_to_remove=array("User Role"); $count=count($fields); $flds=array(); for($i=0;$i<$count;$i++){ if(in_array($fields[$i]->name,$field_to_remove)) unset($fields[$i]); else $flds[]=$fields[$i];//doh, I did not remember a way to reset the index, so creating a new array } return $flds; }
It works neither with
"Mitglieder-Kategorie (Team oder Fan?)"
nor with
Mitglieder-Kategorie (Team oder Fan?)
nor with:
'Mitglieder-Kategorie (Team oder Fan?)'
September 26, 2014 at 2:04 pm #2011511a-spielwieseParticipantFollow-up:
7th:
Capability Manager Enhanced to define custom user roles, if youβre not satisfied with the default wordpress roles (subscriber, contributor,β¦).
The first step is to create your user roleshttps://buddypress.org/support/topic/resolved-different-profile-types-and-different-user-roles/
As ready implied there: I did this – and it works so far.
8th:
Create a xprofile field (selectbox) with the title βUser Roleβ and name the options βBand Roleβ and βFan Roleβ β in my case. You can call them whatever you want. Place this field in the βbaseβ profile group, otherwise it wonβt be shown during registration. Also make the field βrequiredβ. In my case the user canβt decide, if the visibility of the field can be changed.
I did it already, when I installed and activated ‘BP Profile Search’-plugin – and it works.
However, to choosed a dropdown menu and the categories ‘team’ and ‘fan’.
9th:
I modified:
?php function custom_bp_core_signup_user($user_id) { $user_role = strtolower(xprofile_get_field_data('User Role', $user_id)); switch($user_role) { case "Band Role": $new_role = 'band'; break; case "Fan Role": $new_role = 'fan'; break; } wp_update_user(array( 'ID' => $user_id, 'role' => $new_role )); } add_action( 'bp_core_signup_user', 'custom_bp_core_signup_user', 10, 1);
into:
function custom_bp_core_signup_user($user_id) { $user_role = strtolower(xprofile_get_field_data('Mitglieder-Kategorie (Team oder Fan?)', $user_id)); switch($user_role) { case "Team": $new_role = team'; break; case "Fan": $new_role = 'fan'; break; } wp_update_user(array( 'ID' => $user_id, 'role' => $new_role )); } add_action( 'bp_core_signup_user', 'custom_bp_core_signup_user', 10, 1);
(I omitted
<?php
, because I created not a new bp-costum.php, rather inserted the code into my yet existing bp-costum.php. I inserted the modified code above the line?>
.)I did not understand, which effect this insertion should have – but, however, – as far as I see – it causes no harm.
Did anyone understood, for which purpose the above mentioned code is?
10th:
I inserted as well:
//hide the user role select field in edit-screen to prevent changes after registration add_filter("xprofile_group_fields","bpdev_filter_profile_fields_by_usertype",10,2); function bpdev_filter_profile_fields_by_usertype($fields,$group_id){ //only disable these fields on edit page if(!bp_is_profile_edit()) return $fields; //please change it with the name of fields you don't want to allow editing $field_to_remove=array("User Role"); $count=count($fields); $flds=array(); for($i=0;$i<$count;$i++){ if(in_array($fields[$i]->name,$field_to_remove)) unset($fields[$i]); else $flds[]=$fields[$i];//doh, I did not remember a way to reset the index, so creating a new array } return $flds; }
into my bp-costum.php – again above the line
?>
.It does not work:
— threre the user role is still changeable:
— http://1a-spielwiese.de/members/kampfsportlerinnenneuwied/profile/edit/group/1 causes an redirection error. – The redirection error disappears, when I’m not logged in as kampfsportlerinnenneuwied, rather as superadmin.
September 13, 2014 at 3:54 pm #193476In reply to: [Resolved] Customise register page
danbpParticipantThe field NAME in the field group BASE is required. This group is used for the registration page to work. As you already know, it’s also this group who allows you to show custom fields on the registration page.
The NAME field in BuddyPress is intended to receive first and last name and replace the two original fields (first name, last name) coming with WordPress.That said, you can hide this field to users, but you can’t give them the choice to show/hide it.
The above snippet will hide the field NAME to all visitors/members, but not to site admin and the concerned profile.
function bpfr_make_name_members_only( $retval ) { //hold all of our info global $bp; // is xprofile component active ? if ( bp_is_active( 'xprofile' ) ) // The user ID of the currently logged in user $current_user_id = (int) trim($bp->loggedin_user->id); // The author that we are currently viewing $author_id = (int) trim($bp->displayed_user->id); // user can see only his name && admin can see everyone if ($current_user_id !== $author_id && !current_user_can('delete_others_pages') ) { $retval['exclude_fields'] = '1'; } return $retval; } add_filter( 'bp_after_has_profile_parse_args', 'bpfr_make_name_members_only' );
Add this to your child-theme functions.php or to bp-custom.php
September 5, 2014 at 8:59 pm #189703ChiefAlchemistParticipant=> re: “Note that you need to add the correct id(s) for exclude_fields.”
Thanks shanebp. But is this the only way? I mean, I can’t do mucking with the code every time the client wants something new? Can I?
=> re: …/buddypress-xprofile-custom-fields-type/
“Add new visibility setting “Nobody”. Hide the field to all members.”
So this means, I presume that custom visibility is possible. Yes?
That said, I want to use standard fields, but I want to create the list via code, and not have to do it manually. Not possible? Mind you, it could be cause I’m new to BP but I’m trying to where / how the profile definitions are stored. I presume it’s an array, or close. So I want to do that but with code.
Thanks again
September 5, 2014 at 8:09 pm #189699shanebpModeratorI 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/August 26, 2014 at 1:13 pm #188504In reply to: [Resolved] Nobody visibility
danbpParticipantAnother 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' );
August 26, 2014 at 11:44 am #188500In reply to: [Resolved] Nobody visibility
danbpParticipantoh 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');
August 18, 2014 at 9:35 pm #187166mrapinoParticipantOkay, 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/August 16, 2014 at 11:46 pm #187041danbpParticipantWould 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. πAugust 13, 2014 at 9:30 am #186516danbpParticipantHi @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' );
June 6, 2014 at 9:08 am #183740In reply to: Remove profile links
CommonEasyParticipantsorry 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 ?
June 5, 2014 at 10:06 pm #183705In reply to: Pulling from existing custom fields
compixonlineParticipantHi –
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.
June 4, 2014 at 8:57 am #183636In reply to: How add filter to bp_the_profile_group_field_ids?
Iurie MalaiParticipantCan 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.
May 27, 2014 at 6:35 pm #183381Iurie MalaiParticipant@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');
May 21, 2014 at 11:57 am #183188danbpParticipantSince 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' );
May 18, 2014 at 8:48 am #183075In reply to: How add filter to bp_the_profile_group_field_ids?
danbpParticipantHi @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 hereYou 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 ? π
April 12, 2014 at 3:33 pm #181170In reply to: Buddypress x-profile visibility doesn't work
serksParticipantHi 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 | HideDisplay Avatar On Profile
Show | HideSubscribed Member Badge
Show | Hideetc.
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
-
AuthorSearch Results