# Custom function action logic/formatting in Pinegrow WP

**URL:** <https://forum.pinegrow.com/t/custom-function-action-logic-formatting-in-pinegrow-wp/9079>\
**Category:** WordPress\
**Created:** [August 18, 2024, 10:42am UTC](https://forum.pinegrow.com/t/custom-function-action-logic-formatting-in-pinegrow-wp/9079 "2024-08-18T10:42:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muoto](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@muoto](https://forum.pinegrow.com/u/muoto)\
**Post date:** [August 18, 2024, 10:42am UTC](https://forum.pinegrow.com/t/custom-function-action-logic-formatting-in-pinegrow-wp/9079/1 "2024-08-18T10:42:09Z")

</div>

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

```auto
<?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

---

<div class="post-metadata">

**Author:** ![sinanisler](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/sinanisler/32/6380_2.png) [@sinanisler](https://forum.pinegrow.com/u/sinanisler)\
**Post date:** [August 20, 2024, 1:27pm UTC](https://forum.pinegrow.com/t/custom-function-action-logic-formatting-in-pinegrow-wp/9079/2 "2024-08-20T13:27:28Z")

</div>

thats not how you get all users get\_field gets the custom fields not users

here try this

```auto
<?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

---

<div class="post-metadata">

**Author:** ![muoto](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@muoto](https://forum.pinegrow.com/u/muoto)\
**Post date:** [August 20, 2024, 2:33pm UTC](https://forum.pinegrow.com/t/custom-function-action-logic-formatting-in-pinegrow-wp/9079/3 "2024-08-20T14:33:54Z")

</div>

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.
