0
    function ld_reports_plus_register_submenu_page(){
    add_submenu_page(
        'ld-reports-plus',
        'LearnDash Reports Plus Settings',
        'Report Settings',
        'manage_options',
        'ld-reports-plus-settings',
        'ld_reports_settings_submenu_page'
    );
add_settings_section(
      'bp_reg_fields',                          //Name of the section
      'BuddyPress Profile Fields',                      //Title for the  section
      'ld_report_bp_section_callback_function',                         //Callback function for the section
      'ld-reports-plus-settings'                //Page where the section will be located
  );               
add_settings_field(
    'ldrp_bp_options',                                  //Name of the field
    'BuddyPress Options',                               //Title for the field
    'ld_report_bp_fields_callback_function',                            //Callback function for the field
    'ld-reports-plus-settings',                                 //Page where the field will be located
    'bp_reg_fields' );                             //Section where the field will be located
register_setting( 'ld-reports-plus-settings', 'ldrp_bp_options' );

}
add_action( 'admin_menu', 'ld_reports_plus_register_submenu_page' );

function ld_reports_settings_submenu_page(){  
  echo '<div class="wrap">';     
    echo "<h1>" . __( 'LearnDash Reports Plus', 'ld-reports-plus' ) . "</h1>";
    echo '<form method="post" action="options.php">';        
      settings_fields('ld-reports-plus-settings');
      do_settings_sections('ld-reports-plus-settings');      
      submit_button('Add Report Fields');          
    echo '</form>';
  echo '</div>'; 
}

function ld_report_bp_section_callback_function(){
echo '<p>Add BuddyPress Registration Field data to LearnDash Reports.</p>';
function ld_report_bp_fields_callback_function(){
    $profile_groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
    if ( !empty( $profile_groups ) ) {
    foreach ( $profile_groups as $profile_group ) {
           if ( !empty( $profile_group->fields ) ) {                
               foreach ( $profile_group->fields as $field ) {
                //echo $field->id . ' - ' . $field->name . '<br/>';
         $options = get_option( 'ldrp_bp_options' );
                echo '<input type="checkbox" id="' . $field->id  . '" name="' . $field->name . '" value="1"' . checked( 1, $options[$field->id], false ) . '/>';
                echo '<label for="' . $field->name . '">' . $field->name . '</label>' . '<br/>';
               }
           }
       }
    }
}
}
-1

You can use the function xprofile_get_field_data( $field, $user_id, $multi_format)

 * @param mixed  $field        The ID of the field, or the $name of the field.
 * @param int    $user_id      The ID of the user.
 * @param string $multi_format How should array data be returned? 'comma' if you want a
 *                             comma-separated string; 'array' if you want an array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.