Search code examples
wordpressfieldadminbuddypress

BuddyPress Xprofile fields to display on "wordpress user edit admin panel"


I am building a buddypress/bbpress, website with xprofile registration fields. I am using New User Approve plugin to approve each users manually since we need to check information of each user before they get activated.

Problem here is, I am unable to check/view the xprofile field values in Wordpress user edit admin panel. All I have is the username change password, changing roles etc. I want the admin panel to display the extra information of the registered user so that I can check the info and approve . Anyone can help me out to solve this problem.


Solution

  • Might be similar to this.. haven't tried the code though.... Replace the key value 'xprofile_key_birthday' with actual xprofile keys in Buddypress DB.

    Note: This code only displays the values on the edit screen and doesn't insert or update anything.

    <?php 
    add_action( 'show_user_profile', 'showmy_extra_profile_fields' );
    add_action( 'edit_user_profile', 'showmy_extra_profile_fields' );
    function showmy_extra_profile_fields( $user ) { ?>
        <h3>Extra profile information</h3>
        <table class="form-table">
            <tr>
                <th><label>xprofile_key_birthday</label></th>
                <td>
                    <?php 
                    if( function_exists( 'xprofile_get_field_data' ) ) {
                        $xprofile_value = xprofile_get_field_data('xprofile_key_birthday', $user->ID );
                    }
                    else {
                        $xprofile_value = '';
                    }
                    ?>
                    <input type="text" name="xprofile_key_birthday" id="xprofile_key_birthday" value="<?php echo esc_attr( $xprofile_value ); ?>" class="regular-text" readonly />
                </td>
            </tr>
    
        </table>
    <?php 
    }
    ?>