Skip to main content

benecaster_guest_manager_before_save_guest

Action Premium guest-manager

Fires before a guest is created or changed on Benecaster → Guests (or through POST benecaster-guest-manager/v1/guests and PUT, PATCH …/guests/{id}), once the request has validated. Not fired for a refused request.

Parameters

Name Type Default Description
$guest_id int — The guest's post id, or `0` for a guest about to be created
$fields array — Only the keys sent, cleaned: `name`, `title`, `organization`, `bio`, `website`, `social` (a list of `{ platform, url }`), `publications` (the whole list, each `{ title, url, year, type, affiliate, outlinks_id }`), `photo_id`, `email` (the guest's private email, trimmed and lowercased; `''` removes it)

Example

add_action( 'benecaster_guest_manager_before_save_guest', function ( int $guest_id, array $fields ): void {
    if ( 0 === $guest_id && isset( $fields['name'] ) ) {
        my_plugin_log( 'Creating guest: ' . $fields['name'] );
    }
}, 10, 2 );

Notes

A guest created by Import Existing Guests fires it too, with $guest_id 0 (Run or watch the guest import from code). Writes made another way (WP-CLI, wp_update_post()) do not fire it. If the write then fails, benecaster_guest_manager_after_save_guest does not fire. Walkthrough: Read, create, change or delete guests from code, as the Guests screen does.

Affects

  • Benecaster → Guests

Need this built rather than just documented? See our services →