WordPress.org

Ready to get started?Download WordPress

Forums

Codepress Admin Columns
[resolved] Show extra user fields from diffrent table (5 posts)

  1. bkng
    Member
    Posted 1 year ago #

    Hi there,

    Im using buddypress and there i use the option of creating custom user fields that you need to fill in with your registration.
    These fiels are stored in a diffrent table (xprofile)

    Now i want these (2) extra fields to show on the admin side when you go to the user option.

    In wordpress in the admin these extra fields do not sho so i thought i could use your plugin for this.

    Only the pluging only looks for extra custom fields in the same table.

    Is there a possibility to have the pluging also to look in a diffrent table then the standard users table (users)?

    This would realy be great for me.

    Thanx in advance,

    Bert

    http://wordpress.org/extend/plugins/codepress-admin-columns/

  2. Tobias Schutter
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Bert,

    Currently my plugin only supports tables that are in WordPress Core. There is not an option to select another table, like the one BuddyPress has added.

    Unfortunately my plugin can not help you with this at this time. I will make a note of it so I will give it another look for perhaps a feature release.

    What you could do in the meanwhile is place this piece of code in your theme's functions.php.

    Make sure you change the $field_name value to your field title that you want to display:

    function modify_user_table_row( $val, $column_name, $user_id )
    {
    	// edit this part
    	$field_name 	= 'fill in the title of your custom buddyPress user field';
    	// stop editing
    
    	if ( 'buddypress_field' == $column_name ) {
    		$val = xprofile_get_field_data( $field_name, $user_id );
    	}
    
        return $val;
    }
    add_filter( 'manage_users_custom_column','modify_user_table_row',10,3);
    
    function add_my_custom_buddypress_user_column( $column)
    {
    	$column['buddypress_field'] = 'buddypress_field';
    
    	return $column;
    }
    add_filter( 'manage_users_columns', 'add_my_custom_buddypress_user_column' );

    Hope this helps you on your way :)

    Tobias

  3. bkng
    Member
    Posted 1 year ago #

    Great and thanx for the info. Will try it out.

    Great plugin BTW.

  4. bkng
    Member
    Posted 1 year ago #

    Hi there and it works like a charm.

    Now im trying to figure out how to add another second field form the sam table. (And then ill stop :-)

    But i cannot seem to figure out wich code to change.

    Sure would appreciate your help.

    Bert

  5. Tobias Schutter
    Member
    Plugin Author

    Posted 1 year ago #

    Great. For two columns use the following:

    function modify_user_table_row( $val, $column_name, $user_id )
    {
    	$field_name 	= 'fill in the title of your custom buddyPress user field'; // edit this value
    	$field_name2 	= 'fill in the title of your custom buddyPress user field'; // edit this value
    
    	if ( 'buddypress_field' == $column_name ) {
    		$val = xprofile_get_field_data( $field_name, $user_id );
    	}
    
    	if ( 'buddypress_field2' == $column_name ) {
    		$val = xprofile_get_field_data( $field_name2, $user_id );
    	}
    
        return $val;
    }
    add_filter( 'manage_users_custom_column','modify_user_table_row',10,3);
    
    function add_my_custom_buddypress_user_column( $column)
    {
    	$column['buddypress_field']  = 'Column title goes here'; // you can edit this value
    	$column['buddypress_field2'] = 'Column title goes here'; // you can edit this value
    
    	return $column;
    }
    add_filter( 'manage_users_columns', 'add_my_custom_buddypress_user_column' );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic