Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'profile fields'

Viewing 25 results - 1,326 through 1,350 (of 3,575 total)
  • Author
    Search Results
  • #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

    modemlooper
    Moderator

    This code is just a start, I did not test to see if field groups will break it but you can get an example of spitting out fields as an object array variable on profile load and then using the variable to get the values instead of requesting each time.

    put this in bp-custom.php

    
    // creates global object array from profile fields
    function bp_profile_fields_array() {
    	global $fields;
    
    	$fields = array();
    
    	if ( bp_has_profile() ) :
    
    		while ( bp_profile_groups() ) : bp_the_profile_group();
    
    			if ( bp_profile_group_has_fields() ) :
    
    				while ( bp_profile_fields() ) : bp_the_profile_field();
    
    					if ( bp_field_has_data() ) :
    
    							$field_name = bp_get_the_profile_field_name();
    							$field_value = bp_get_the_profile_field_value();
    
    							$field = array(
    								'field_name' => $field_name,
    								'field_value' => $field_value,
    							);
    
    							$fields[] =	$field;
    
    					endif;
    
    				endwhile;
    
    			endif;
    
    		endwhile;
    
    	endif;
    
    	return $fields;
    
    }
    add_action( 'bp_before_member_header', 'bp_profile_fields_array' );
    
    // echoes value of field from object array based on param
    function bp_get_single_profile_field( $param ) {
    	global $fields;
    
    	foreach ( $fields as $key => $val ) {
    	   if ( $val['field_name'] === $param ) {
    		   echo $val['field_value'];
    	   }
    	}
    }

    Then in your member templates:

    <?php bp_get_single_profile_field('PROFILE FIELD NAME'); ?>

    Shmoo
    Participant

    In the profile-loop.php ( members/single/profile )

    Instead of this loop.

    
    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    	<?php if ( bp_field_has_data() ) : ?>
    	<tr<?php bp_field_css_class(); ?>>
    		<td class="label"><?php bp_the_profile_field_name(); ?></td>
    		<td class="data"><?php bp_the_profile_field_value(); ?></td>
    	</tr>
    	<?php endif; ?>
    <?php do_action( 'bp_profile_field_item' ); ?>
    <?php endwhile; ?>
    
    Shmoo
    Participant

    I know, but what if I duplicated the code above for all 20 profile fields ?

    – country
    – about
    – gender
    – age

    I would like to know how bad this would be for performance on the site, from my understanding it has something to do with Database Query’s ?

    Trying to make a Tab view of the profile info, on the first tab I would like to show all general stuff and on the second tab I would like to show work info + social media options.

    Henry
    Member

    Hi @macpresss

    What do you mean by ‘export all profile fields by a conditional tag’?

    Doing what you’ve done above is good practice because if Country is an optional field and it has not been completed by the member then nothing will be outputted:

    <?php if ( $data = bp_get_profile_field_data( 'field=Country ' ) ) : ?>
         <!-- do something -->
    <?php endif ?>

    If you’re doing something with a single profile field then there is no need to loop through them all. It’s basically wasted effort and slower performance.

    danbp
    Participant

    hi @matt-mcfarland,

    i’m not a dev but consider this, to get a user ID:

    $user_id = bp_get_member_user_id();

    To answer the sql question, here’s a function that doesn’t exist in buddypress, which let you get the xprofile_group name by it’s ID For inspiration…

    function bpfr_get_xprofile_group_id_by_name( $name = '' ) {
    	global $wpdb;
    	
    	$bp = buddypress();
    	
    	if( empty( $name ) )
    		return false;
    		
    	return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_groups} WHERE name = %s", $name ) );
    }

    For the output, you have to create another function containing at least:

    
    	$user_id = bp_get_member_user_id();
    	$xprofile_group_id = bpfr_get_xprofile_group_id_by_name( 'the groupe name' );
    
    if( !class_exists( 'BP_XProfile_Group' ) )
    		return false;
    		
    	$args = array(
    		'profile_group_id'       => $xprofile_group_id,
    		'user_id'                => $user_id,
    		'fetch_fields'           => true,
    		'fetch_field_data'       => true
    	);

    May this help you !

    #175261
    Henry
    Member

    Hi @noizeburger, glad you finally got this working. I’m sure your tutorial will be helpful to many people too. I especially like the last snippet which shows you how to disable the editing of certain fields on the edit profile screen!

    adamjd
    Participant

    Still no easy solution to this one? It’s odd that BP has been around for so long and more people aren’t having an issue with the extra profile fields not being sent upon registration.

    #175130
    koendb
    Participant

    Could for instance add dropdown boxes with categories to users extended profile pages.
    Get the value of those profile fields from your home template and use it in a query.

    #175121
    noizeburger
    Participant

    Hi again, @henrywright-1

    just wanted to let you know, that I’ve requested some help from the developer of BP Custom xprofile Fields – donmik

    I asked him, if it is possible, to use a custom xprofile field (selectbox) to choose the user role and pass it over to wordpress. He gave me this function or – you can say – hint:

    function custom_bp_core_signup_user($user_id) {
        $user_role = strtolower(xprofile_get_field_data('NAME OF THE XPROFILE FIELD', $user_id));
        switch($user_role) {
            case "role 1":
                $new_role = 'Contributor';
                break;
            case "role 2":
                $new_role = 'Author';
                break;
            default:
            case "role 3":
                $new_role = 'Suscriber';
                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 put this code in my bp-custom.php, but it does not work. I think there’s something missing. Maybe you have an idea, or @modemlooper?

    #175090
    shanebp
    Moderator

    >Wow, so basically in order for members to have access to edit all of the fields that they entered while signing up, we have to pay for a custom plugin to get access to those fields?

    Let me repeat:
    They are accessed on the front-end on a member’s profile page.
    your-site.com/members/peteratomic/profile/

    If it’s your profile or you are an admin, you will clearly see an ‘Edit’ button.

    >Utterly mind-boggling why this functionality isn’t built in to BP.
    It is built into BP.

    #175085
    shanebp
    Moderator

    > they’re totally inaccessible afterward
    They are accessed on the front-end on a member’s profile page.
    your-site.com/members/peteratomic/profile/

    >Clicking the “your profile” link in the backend brings up a page
    In the Dashboard, that link takes you to the DashBoard > User > Edit screen which is a standard WordPress screen.
    If you want to view and edit BuddyPress Extended Profile fields on that screen,
    then you might be interested in this premium plugin:
    http://www.philopress.com/products/bp-dashboard-user-profile-edit/

    #175081
    peteratomic
    Participant

    P.S. I found profile-wp.php and deleted out the fields in my custom template that I don’t want to display, but they still show up. LOST.

    #175053
    shanebp
    Moderator

    We have a premium plugin that shows xprofile fields on the User > Edit screen in the Dashboard:

    http://www.philopress.com/products/bp-dashboard-user-profile-edit/

    #174991
    glyndavidson
    Participant

    Thanks @mercime. Am I right in thinking then, that out of the box, the normal functionality is to have buddypress extended-profile-fields, groups, and member-lists shared across the network?

    I.e. if an admin deletes a group or profile-field from a child-blog, it effects the entire network?

    And, there’s nothing I can do to prevent this without a third party plugin or my own hacks?

    #174973
    Paul Wong-Gibbs
    Keymaster

    No direct way of bulk-editing profile fields; sounds dangerously powerful. If you are a PHP/WordPress developer, or know someone who is, I’d suggest writing a script to make these changes for you.

    #174926
    Hugo Ashmore
    Participant

    You could do this by adding a conditional check around the tr markup in the while loop that generates the field name and data while ( bp_profile_fields() ) : bp_the_profile_field();

    With that check in place you would then remove the bp_the_profile_field_value() function and replace it with something like echo do_shortcode( '[myshortcode user_id=' . bp_displayed_user_id() '] );

    #174906
    auch07
    Participant

    Not utilizing the profile search plugin alone. If you were using a custom registration form like Gravity Forms Registration you could create additional profile groups with the fields worded how you want and the gravityforms registration could automatically update both sets of profile fields accordingly to how you set them up.

    #174699

    In reply to: Member Search

    auch07
    Participant

    Upon further reflection what I had thought would work in fact does not. Does anyone know how I could string together a search for the 2 fields? The issue isn’t the member type itself its that the member types both have profile fields with the same value in it. (IE: Childcare)

    So searching /members/?s=Childcare will return both Employers and Jobseekers that have selected childcare. I would like to be able to filter those results between Employers and Jobseekers.

    #174646
    Henry
    Member

    To my knowledge, profile fields accept HTML. Have you tried inserting tags to see? try adding <strong>test</strong> to a profile field to see if the text is bolded.

    #174619
    noizeburger
    Participant

    Hi @henrywright-1 again,

    your logic is right, but I wanted to avoid editing templates. That’s the reason why I use Buddypress xprofiles acl plugin. This makes it possible to choose which role can see and use the different profile tabs. For the music embed I use BP Profile Widgets, the needed input fields are only visible to members with the userrole “band”, all other members can only see the output of the widget – music.
    Your last post makes me think about other things that could be done beside those plugins I use, but that goes too far at the moment. As I tried to explain before, the really important thing about passing over the roles to xprofile-fields would be the possibility to show the roles for each member in a searchable and clickable way that always leads the user to the right member-directory.
    Maybe you have more ideas, however, thanks for your ideas and help.

    #174519
    Martyn_
    Participant

    * Better options for users to self delete

    Expanding. Without backend access, it would be nice for a site allow a user to delete in several ways. Purge all their profile fields and networks (‘destroy all personal data’), Retain their profile fields and networks whilst making it look like they have vanished (‘hide’ if you like), Delete Uterly.

    * Multiple networks. We have friends, and with plugins one sided friendships (aka followers). sometimes its useful to have different types of relationships identified – “close friends” or “have done business with” or “merely online buddies”. It would be nice for an admin to be able to define additional types of friendships either independently, or by associating a scale (an integer valued friendship, 1=I want to see your feed stuff 2=online mates 3=actual real life chums 4=we’re married).

    #174474
    noizeburger
    Participant

    Thank you @henrywright-1,

    this would be a nice alternative to my own approach, but what about my original idea? Remember you asked the same question in another thread few weeks ago.

    If there would be a way to pass over the different user-roles to xprofile-fields there would be no need to create templates. You could output the field in the member-loop and make it searchable. This would be the simplest way. What do you think about it?

    As an example: a user registers on my site as “band” (which is a wordpress user role). The selected field would be inserted into a (maybe) hidden xprofile-field also called “profiletype”. This field could be echoed everywhere inside buddypress (clickable, searchable). I know this could be done with only xprofile-fields too, but without the possiblity to use bp-xprofile-acl an the advantage of different user capabilities. Am I clear?

    #174451
    Henry
    Member

    @noizeburger I think I get what you mean. To show all members of type ‘fan’ in a “fan directory” you would do this

    <?php
    
    $fans = get_users( array( 'role' => 'fan' ,'fields'=>'ID') );
    $fans = implode( ',', $fans );
    
    if ( bp_has_members( '&include=' . $fans ) ) :
        while ( bp_members() ) : bp_the_member();
            // you can output whatever you like here such as member name, avatar, role and so on
            // we will output just member name for now
            echo bp_member_name();
        endwhile;
    
    else:
        echo 'Sorry, no fans';
    endif;
    ?>
    #174355
    hughshields
    Participant

    The WPUF Pro plugin uses a field they are calling “Meta Key” on each of their user registration fields. The BP Integration Add On maps each of the custom registration fields to the Buddypress XProfile field. Unfortunately the value in the Meta Key field seems to be not syncing with whatever value Buddypress assigns to member profile fields. So I end up with two sets of member profile fields that are not updating correctly.
    So I am trying to locate the naming convention for Buddypress Extended profile fields or find out what each field is called. What the user meta value is I guess?
    I am installing PHP MyAdmin and will try to find there but hoped there was a naming convention or place to see this in the Admin.

Viewing 25 results - 1,326 through 1,350 (of 3,575 total)
Skip to toolbar