Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'hide xprofile fields'

Viewing 25 results - 76 through 100 (of 129 total)
  • Author
    Search Results
  • #129738
    Hugo Ashmore
    Keymaster

    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.

    modemlooper
    Moderator

    Just read you don’t want to edit home.php. There isn’t a filter for privacy like there is with messages for showing profile sections. Messages and xprofile fields has logic for output and can be filtered but the actual page needs a code edit.

    #24244
    kirkslater
    Participant

    Hi

    I’m sure this has been answered before but couldn’t track it down.

    I have 2 user roles, and I don’t want them to have the same profile options to fill in. I’ve tried “BuddyPress xProfiles ACL” plugin but it only hides fields ie:

    Role 1 can fill in “contact details” and can see “contact details” on every profile
    Role 2 can’t fill in “contact details” and can’t see “contact details” on any profile

    So this is no good. What I need is role 1 and 2 to have their own profile fields

    Is this possible? Please let me know if I haven’t been clear

    Cheers

    mistercyril
    Participant

    Hello,

    I have a custom select box profile field and one of the values has a (‘) in it.

    I.E. “besoin d’aide”

    Now it displays in the drop down select box as: “besoin d’aide”

    How can I hide that backslash?

    Thanks,
    C.

    Bowe
    Participant

    Hi guys,

    I’m using the following snippet to display certain xprofile fields in my member-header.php:

    `

    Occupation:

    `

    This works fine, but it also shows when the profile field is empty. So I would like to hide them when empty, but I can’t figure out how to do this. I’m pretty sure @DJPaul made a snippet once, but I could not find it again. I imagine it must have been something like:

    if xprofile field “Country” has data
    Country: United States
    else
    *blank*

    Ofcourse this needs to be proper php (which I can’t write :D). If someone has this working, or could help me figure this out, it would be pretty awesome!

    #88998

    In reply to: Hide profile field

    r-a-y
    Keymaster

    Tested just now, works for me.
    You need to use the profile id #.

    Go to your profile field setup and check the ID by putting your mouse over the “Edit” field. The ID # is field_id.
    For example, “Name” is 1.

    Either that or go to your DB and manually look up the profile field id in the wp_bp_xprofile_fields table.

    You can also use any profile template tag and do your conditional.

    If you wanted to use the profile name, use bp_get_the_profile_field_name() instead.

    peterverkooijen
    Participant

    @thelandman, in my solution I use javascript to generate the username from the weird semi-optional xprofile fullname field, hide the username field on the form, use the email login plugin so members don’t need the username to log in, add more custom code to synchronize the fullname and the fullname-derived username to all the various similar fields in the database, etc. It’s messy, but somewhat workable.

    The point is that it should not be that hard. Using full names, Firstname Lastname, should be part of the core. Seeing that none of this is fixed in 1.2+ and probably will never be fixed, I have no plans to upgrade to newer versions of Buddypress and will continue developing my version as a fork, more suited for professional and business use. If anyone is interested in working with me on that, please contact me directly.

    Gene53
    Participant

    Done, thanks again.

    Gene

    jivany
    Participant

    So it works? Tag the topic as resolved. ;)

    Gene53
    Participant

    Believe it or not, it didn’t work when I changed Username for 1 but it did when I added ,3 (still don’t know what the 3 is for, LOL).

    Does that mean I don’t really need the funky function and simply change the <input type=”hidden” … > in edit.php or should I just leave things as they are now that it seems to work?

    EDIT: when I added ,3, I couldn’t change the value of the next field and “1” still gives me the error…

    EDIT 2: ROFLOL, it didn’t work because I omitted the , (colon) after the 1. Now everything seems to work.

    Thanks again, I really appreciate your help.

    Gene

    jivany
    Participant

    It becomes just string manipulation. Create a new function (my_funky_function) and do something like this:

    function my_funky_function() {
    echo str_replace( "username","", bp_get_the_profile_group_field_ids() );
    }

    Then replace the bp_the_profile_group_field_ids() call in edit.php (in your child theme of course) with my_funky_function().

    I think that will work but it’s not tested. ;)

    Edit:

    Oh, sorry, I’m sort of wrong. This is what I get in my edit.php form in the HTML:

    <input type="hidden" name="field_ids" id="field_ids" value="1,3" />

    Field_id 1 is the Username for me. You just need to filter that out so the str_replace call should be “1,” instead of “username”.

    Gene53
    Participant

    Makes sense but I haven’t a clue on how I could code such a function… That’s way above my programming skills.

    jivany
    Participant

    <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_group_field_ids() ?>" />

    That line is your problem. Well, more specifically, the call to bp_the_profile_group_field_ids() which creates a list of the expected field names.

    Unfortunately it doesn’t have a filter so you’d have to clone and own the function into your functions.php file and manually filter out the “username” field from the string that gets generated.

    Make sense?

    Gene53
    Participant

    Hey jivany,

    I was sort of wondering if that would happen

    LOL, it sure did so I’m wondering if there was a workaround, such as the field not being visible (or non editable) but would still send the name field when the form is submitted.

    Darn, I miss the good old days (phpBB 1 and 2) when you only had to comment out code in templates…

    jivany
    Participant

    Oh, nope, it probably means that the code is actually checking that the field ‘username’ should be getting updated. I was sort of wondering if that would happen. ;)

    Gene53
    Participant

    Oops, spoke too soon, if I edit anything in group 1 (where Username is hidden), I get “Please make sure you fill in all required fields in this profile field group before saving” even though everything has been filled.

    Oh well, back to the drawing board. Maybe the code wasn’t inserted in the right place and/or I have to add HTML but I haven’t a clue as to what I should add.

    Gene53
    Participant

    @jivany Wow, thanks, I simply added:

    <?php if ( 'Username' == bp_get_the_profile_field_name() ) : ?>

    <?php else : ?>

    under:

    <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?>

    inserted a endif where you indicated, didn’t do any HTML formatting and the Username field is now hidden.

    Thanks again!

    Gene

    jivany
    Participant

    Well, yes, you should be able to make the username field non-editable. I would assume the username field is a “textbox” type. In edit.php, you should be able to just filter out the username field and not create a form “textbox” HTML element. So, in member/single/profile/edit.php around line 21, add in a check something like:

    <?php if ( 'username' == bp_get_the_profile_field_name() ) : ?>
    // Just display the Username with bp_the_profile_field_name() and add HTML to style how you want.
    <?php else : ?>
    // Do the existing <label... code on line 23 and 24
    <?php endif; ?>

    Now, a creative user might still be able to circumvent your little hack and submit their change directly to the form. I see a nonce being used though in the form so that might not be too much of a concern after all.

    Gene53
    Participant

    Thanks guys, I’ll drop the idea being that it’s way too complicated for what it’s worth.

    My reason for having the mandatory name field only (which I renamed Username) in group 1 is that the site I’m working on is username only and thanks to Brajesh Singh’s modifications in edit.php, group 1 can’t be edited by the users.

    So, my only alternative is to restore the original edit.php file, move the group 2 fields to group 1 so they may be filled out during registration but I wonder if there would be a simple way to hide or “gray out” the name field in edit.php so the user can’t change it.

    Paul Wong-Gibbs
    Keymaster

    So, yes, by default, the register page only shows group 1 (the “base” group). You only retrieve one group via the profile_group_id= parameter in the bp_has_profile() call.

    So, by default, this happens:

    What I’m trying to accomplish is to hide groups 3 and 4 on the registration page not to overwhelm the user with a bunch of fields to fill out during sign-up, those fields can be filled out once the user has activated her/his account via “edit profile”.

    There have been other threads on the forum regarding showing more than one profile group on the registration page; I found several, but take a look at https://buddypress.org/forums/topic/all-fields-for-registration. It’s probably going to be really difficult to implement unless you have a decent understanding of PHP.

    jivany
    Participant

    Nope, I don’t think so. I was thinking you could remove the ‘profile_group_id=1’ arg from bp_has_profile but that doesn’t seem to allow the registration page to show more groups. I guess it appears that the only “required” fields for registration are the required ones in the Base group.

    Might be worth opening a ticket on this one to see if that is the expect behaviour. Alternatively, ping R-a-y or DJPaul and see if they know.

    Gene53
    Participant

    Nope, only getting group 1. I wonder if:

    <?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    can be modified to fetch group 2 also.

    LOL, this is driving me nuts…

Viewing 25 results - 76 through 100 (of 129 total)
Skip to toolbar