Custom function action logic/formatting in Pinegrow WP

Hi everyone.

I’m using Pinegrow to create custom blocks for a theme and having some trouble understanding how to add custom functions in Pinegrow Wordpress actions.

The functions work fine when added to the exported blocks php files directly. But fails when added to the actions custom code field in the actions panel. Wich isn’t ideal since it gets overwritten on export.

Is there something special regarding the logic or formatting that I’m missing?

My function looks like this

<?php
$users = get_field("users");
if( $users ): ?>
<ul class="volunteers-list">
    <?php foreach( $users as $user ): ?>
        <li>
            <a href="<?php echo esc_attr($user->user_url); ?>"><?php echo $user->display_name; ?></a>
        </li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

Can’t find anything mentions for this in the documentation

Would be super thankful for any help on this
Cheers

thats not how you get all users get_field gets the custom fields not users

here try this

<?php
$users = get_users();
if ( $users && is_array($users) ): ?>
    <ul class="volunteers-list">
        <?php foreach ( $users as $user ): ?>
            <li>
                <a href="<?php echo $user->user_url; ?>"><?php echo $user->display_name; ?></a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

and use google/chatgpt when you are writing code if you don’t know what function does what

1 Like

Thanks for looking into this @sinanisler

My function wors fine. I missed that the custom code field apparently doesn’t support nested php tags.

Reformatting the code fixed my problem.

1 Like