function bp_user_meta_box() { add_meta_box( 'metabox_id', __( 'Metabox Title', 'buddypress' ), 'bp_user_inner_meta_box', // function that displays the contents of the meta box get_current_screen()->id ); } add_action( 'bp_members_admin_user_metaboxes', 'bp_user_meta_box' );
This function outputs the content of the meta box. The skies the limit here. You can add almost any information to want. You could have a meta box that you enter notes about that user or show information from another plugin.
function bp_user_inner_meta_box() { ?> <p>This is where you write your form inputs for user settings. Or you can output information pertaining to this user. For example, the Achievements plugin could show the users badges here. </p> <?php }
This function saves any form inputs you might include in the meta box.
function bp_user_save_metabox() { if( isset( $_POST['save'] ) ) { $user_id = isset( $_GET['user_id'] ) ? $_GET['user_id'] : 0; // you will need to use a $_POST param and validate before saving $meta_val = isset( $_POST['form_value'] ) ? sanitize_text_field( $_POST['form_value'] ) : ''; // the $meta_val would be a $_POST param from inner meta box form update_user_meta( $user_id, 'user_meta_key', $meta_val ); } } add_action( 'bp_members_admin_update_user', 'bp_user_save_metabox' );