I have a very simple requirement to start.
I have a function that is called via a shortcode.
I know I can get a single value by doing the following
function cardkey() {
$user = wp_get_current_user();
$card_key = $user->card_key ;
return $card_key;
}
add_shortcode('testercode', 'cardkey');
So I want to return from a repeater something like this in a table
Name, Age, DoB, Phone, Email
I know how to setup the table header, so I then have this shortcode based off this page: https://www.advancedcustomfields.com/resources/repeater/
Not that I am trying just to get one value returned, but I get nothing, and there is data in the field.
function showmembers() {
$rows = get_field('household_members');
if( $rows ) {
$htmlcode = '<tr>';
foreach( $rows as $row ) {
$htmlcode += '<td>'.$row['age'].'</td>';
}
$htmlcode += '</tr>';
}
return $htmlcode;
}
add_shortcode('householddata', 'showmembers');
Solved
The answer is this:
get_field('household_members', 'user_'.get_current_user_id() );