This code worked for me:
function hora_inicio_podcast( $field ) {
$programas = get_field('podcast_programa');
if( $programas ):
foreach( $programas as $programa ):
$horapInicio = get_post_meta($programa->ID, 'hora_de_inicio', true);
$fecha = date("s:i:H", $horapInicio);
$field['default_value'] = $fecha;
return $field;
endforeach;
endif;
return $field;*/
}
add_filter('acf/load_field/name=podcast_hora_inicio', 'hora_inicio_podcast');
Hi John,
thanks for your help.
I’ll try to solve it using your guidelines and I’ll post the solution here if I get to it.
Regards
Daniel,
now you have your earned recognition with the ‘case solved’ badge.
I’ve managed the change with the developer.
Thanks again for your help!
I think I’ve set it on my last post by mistake and don’t know how to change it. So sorry… Could any Admin user change it, please?
Hi Daniel!
I’m sorry, I’ve been out of the office for the last couple of days and didn’t answer your last reply.
Your code works like a charm, it shows name + roles the way I needed.
Thank you so much for your patience and help!
Best regards!
Yes, I applied the exact code you sent.
Here are the dumped values I get, the one I’d like to show next to the name is “voluntario”.
Thanks a lot for your help!
Thanks for the approach,
it doesn’t show anything 🙁
Thanks Daniel for your help!
After dumping it, this is what I get (attached image)
“Role” does not appear… and I don’t know where to find it.
I also tried this code, getting the role from the user ID (112 is the id of a user on the list) and it works, but I don’t know how to pass the user ID as a parameter.
<h3>Asistentes</h3>
<div>
<?php $users = get_field('asistentes'); ?>
<ul>
<?php foreach ($users as $user): ?>
<li>
<p><?php echo $user['display_name']; ?> - <?php $user_info = get_userdata(112);
echo 'User roles: ' . implode(', ', $user_info->roles) . "\n";
?></p>
</li>
<?php endforeach; ?>
</div>
I think I’m getting closer… What am I missing?
Thanks in advance!
John,
As you may have already noticed, I’m very amateur on this 🙁
I’ve made that change and get the same error message.
Here’s the code:
<h3>Asistentes</h3>
<div>
<?php $users = get_field('asistentes'); ?>
<ul>
<?php foreach ($users as $user): ?>
<li>
<p><?php echo $user['display_name'];
echo 'User roles: ' . implode(', ', $user_info['role']) . "\n";?></p>
</li>
<?php endforeach; ?>
</div>
This is line 38, which triggers the error:
echo 'User roles: ' . implode(', ', $user_info['role']) . "\n";?></p>
Any further solution?
Thanks a lot!
Thank you John for your answer!
You’re right, the field returns an array.
This is the code I’ve used, then:
<?php foreach ($user as $user): ?>
<li>
<p><?php echo $user['display_name'];
echo 'User roles: ' . implode(', ', $user_info['roles']) . "\n";?>
</p>
</li>
<?php endforeach; ?>
And got this error message:
Warning: implode(): Invalid arguments passed in /home/volunta6/staging/1/wp-content/plugins/acf-enhanced-message-field/acf-enhanced-message-v5.php(56) : eval()’d code on line 38
Any further help on this would be very appreciated!
OK, thank you John.
That’s too advanced for me.
I’ll figure out another solution.
Hi again,
Any idea about how to adapt this code to allow selecting multiple authors?
I’ve tried to allow multiple values to that field, but only the first one is saved.
Thanks again!
You’re right, there was a typo.
Thanks!
Hi,
I need this feature, but I don’t know where I should put this code.
I tried on functions.php but it didn’t work.
Thanks in advance for your help!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.