# Trigger custom field-refresh after changing the page slug

**URL:** <https://forum.getkirby.com/t/trigger-custom-field-refresh-after-changing-the-page-slug/15620>\
**Category:** Questions\
**Tags:** v3\
**Created:** [September 12, 2019, 4:34pm UTC](https://forum.getkirby.com/t/trigger-custom-field-refresh-after-changing-the-page-slug/15620 "2019-09-12T16:34:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pst](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@pst](https://forum.getkirby.com/u/pst)\
**Post date:** [September 12, 2019, 4:34pm UTC](https://forum.getkirby.com/t/trigger-custom-field-refresh-after-changing-the-page-slug/15620/1 "2019-09-12T16:34:52Z")

</div>

Hi, I like to display the new slug in my custom field, after the slug was changed. At the moment the field updates only after a hard page refresh.

Can I somehow trigger a custom-field-method from the page.changeSlug:after Hook?

```php

Kirby::plugin('my/plugin', [
    'hooks' => [
        'page.changeSlug:after' => function ($newPage, $oldPage) {
            // trigger field method here????
        },
    ], 
    'fields' => [
        'pageurls' => [
            'props' => [
                'label' => function (string $label) {
                    return $label;
                },
            ],
            'computed' => [
                'urls' => function () {
...

```

How can I do this?

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [September 12, 2019, 4:42pm UTC](https://forum.getkirby.com/t/trigger-custom-field-refresh-after-changing-the-page-slug/15620/2 "2019-09-12T16:42:03Z")

</div>

> [@pst](#):
>
> At the moment the field updates only after a hard page refresh.

Is this on the Kirby Panel UI?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 12, 2019, 5:14pm UTC](https://forum.getkirby.com/t/trigger-custom-field-refresh-after-changing-the-page-slug/15620/3 "2019-09-12T17:14:48Z")

</div>

Not quite sure what you are doing in your field. But it think you should update tithe page’s field value in your hook. Or have you already tried that?

---

<div class="post-metadata">

**Author:** ![pst](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@pst](https://forum.getkirby.com/u/pst)\
**Post date:** [September 12, 2019, 6:32pm UTC](https://forum.getkirby.com/t/trigger-custom-field-refresh-after-changing-the-page-slug/15620/4 "2019-09-12T18:32:24Z")

</div>

@ahmetbora: Yes, it´s in the Kirby Panel UI.

@texnixe: how would i do that?

here´s a image of the field:

 ![18](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/6/634ed9ff476ae23872109e6eb08441c86af25a72.png)

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 12, 2019, 6:43pm UTC](https://forum.getkirby.com/t/trigger-custom-field-refresh-after-changing-the-page-slug/15620/5 "2019-09-12T18:43:52Z")

</div>

> [@pst](#):
>
> ‘page.changeSlug:after’ =\> function ($newPage, $oldPage) { // trigger field method here??? }, ],

Like this:

```auto
    'page.changeSlug:after' => function ($newPage, $oldPage) {
        $newPage->update(['fieldname' => $newPage->slug()]);
      }

```

This should immediately show the new value. I don’t know how the data is stored in your field, you might have to adapt the code, also, since this looks you are using a multilange site, you would have to pass the language code as second parameter if you want to update other languages then the default language (might not be intended in this case).

---

<div class="post-metadata">

**Author:** ![pst](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@pst](https://forum.getkirby.com/u/pst)\
**Post date:** [September 12, 2019, 10:27pm UTC](https://forum.getkirby.com/t/trigger-custom-field-refresh-after-changing-the-page-slug/15620/6 "2019-09-12T22:27:02Z")

</div>

@texnixe: Thank you! I could rewrite the field with your provided information.
