I'm trying to retrieve my group field that I've added to the user profile with the user meta Addon, I'm trying to adapt output code that I've used before from a page meta but it's not working for user meta.
Please see my code below:
User Metabox:
<?php
add_filter( 'rwmb_meta_boxes', 'am_dz_statement_metabox' );
function am_dz_statement_metabox( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Statements', 'your-text-domain' ),
'id' => 'statements',
'type' => 'user',
'fields' => [
[
'name' => __( 'Statements', 'your-text-domain' ),
'id' => $prefix . 'am_statements',
'type' => 'group',
'collapsible' => true,
'clone' => true,
'sort_clone' => true,
'fields' => [
[
'name' => __( 'Statememnt File', 'your-text-domain' ),
'id' => $prefix . 'AM_statment_file',
'type' => 'file_advanced',
],
[
'name' => __( 'Statement Title', 'your-text-domain' ),
'id' => $prefix . 'AM_statement_title',
'type' => 'text',
],
],
],
],
];
return $meta_boxes;
}
Shortcode:
<?php
add_shortcode('am_dz_statements', function() {
$statements = rwmb_meta( 'statements', ['object_type' => 'user'], $user_id );//Slides needs to be var in the module
if ( empty( $statememnts ) ) {
return '';
}
if ( ! empty( $group_values ) ) {
foreach ( $group_values as $group_value ) {
$value = isset( $group_value[$sub_field_key] ) ? $group_value[$sub_field_key] : '';
echo $value; // Display sub-field value
}
}
$counter = 0;
foreach ( $statements as $statement ) {
$counter++;
$statementfile = $statement['AM_statment_file'];
$statementtitele = $statement['AM_statement_title'];
$output .= '<div id="am-statement-' . $counter .'" class="am-statement">';
$output .= '<h2 class="fm-slide-title">';
$output .= '<a href="' . . '">' . $statementtitele . '</a>';
$output .= '</h2>';
$output .= '</div>';
}
return $output;
} );