• On the post editing page, I add a widget to create a new user and assign them as the author of the post.

    My widget calls wp.data.dispatch('core').saveUser({ … }) and creates a new user.

    I’m not sure how I can “update” the list of authors in the Author dropdown so that the newly created user is loaded there.

    I tried calling
    await wp.data.dispatch('core').invalidateResolutionForStore('core')
    wp.data.dispatch('core/editor').editPost({author: newUserId})

    But this leads to the fact that the new user ID is set BEFORE the list of available users is updated.

Viewing 1 replies (of 1 total)
  • With react you only have to update the attributes to force a reload. So if you have saved the new user, force an attribute update. I have already done this with timestamps, for example.

    object.setAttributes({
     date: new Date().getTime(),
    })
Viewing 1 replies (of 1 total)
  • The topic ‘On the post editing page, how do I create a new user and update the Author field’ is closed to new replies.