Skip to main content

Restyle the guest’s own Guest portal form, or act when a guest sends changes

Premium Intermediate Guest Manager

The page a guest’s Guest portal link opens (see Invite a guest to the Guest portal, or stop their link, from code, and change the invitation email): Edit Your Guest Profile at /guests/{post_name}/edit/?key={64 hex}, or under plain permalinks the guest page’s address plus &benecaster_guest_edit=1&key=…. A guest changes Title, Organization, Bio, Photo (a new JPEG, PNG or WebP under 2 MB, or Remove my photo), Website and Social links, never Name or Email, and presses Submit for approval. The changes wait until the podcaster approves them.

  • What decides the page. The key, first: a wrong, expired or stopped key, the Guest portal switched off, or a guest that is not published shows one plain message, status 403, and nothing of the guest. The page is noindex, nofollow, never cached, sends Referrer-Policy: no-referrer, and is never redirected to the guest’s own page.
  • A submission needs a nonce made for that guest and that key, counts against the key’s 10 an hour (refused ones too), is cleaned and refused exactly as PUT, PATCH /guests/{id} cleans and refuses (see Read, create, change or delete guests from code, as the Guests screen does), with caps of 200 characters for Title and Organization, 5,000 for Bio and 10 social links, and needs at least one change. A photo is judged by its bytes, not its name, and kept under a random name in {uploads}/benecaster/guest-manager-pending/: never an attachment, never on a page. Erasing the guest’s personal data or deleting the guest deletes it, and opening the Waiting for Approval list deletes any file there over an hour old that no waiting change names.
  • Nothing a guest sends is shown on any public page, shortcode, feed or public function before approval.
  • Pending changes are private guest meta, { fields, photo, submitted }: fields holds only the fields that differ from the public profile, already cleaned (title, organization, bio, website, social as [{ platform, url }]); photo is null, "remove" or { file, mime }; submitted is UTC Y-m-d H:i:s. A later submission replaces an earlier one. Read them through the approval routes in Approve or decline guests’ Guest portal changes from code, and change the approval emails, not the meta.

The hooks:

  • benecaster_guest_manager_before_submit_guest_changes( int $guest_id, array $fields, string|array|null $photo ), before the changes are stored; benecaster_guest_manager_after_submit_guest_changes( int $guest_id, array $pending ), once stored.
  • benecaster_guest_manager_guest_form_data( array $form, int $guest_id ): array ($guest_id is 0 on the plain-message page): state (invalid, form or thanks), message, and on the form name, values, photo_url, errors, action, fields, nonce, max_bytes, max_lengths, max_social, blank_rows, pending_since. Values are raw; the template escapes them. action carries the guest’s key: print it only as the form’s address.

The template is guest/edit.php; {theme}/benecaster/guest/edit.php wins. It takes no variables: it reads BenecasterGuestManager\Portal\GuestForm::data() and draws the theme’s header and footer around it. Keep enctype="multipart/form-data", the field names in fields, the nonce and the submit button’s name, or nothing is accepted. Classes: benecaster-guest-form with __heading, __message, __name, __intro, __pending, __error, __form, __field, __photo, __current-photo, __remove-photo, __social, __social-row, __hint and __submit.

Code

<?php
// Email the show's producer the moment a guest sends changes.
add_action( 'benecaster_guest_manager_after_submit_guest_changes', static function ( int $guest_id, array $pending ): void {
    wp_mail( 'producer@example.com', 'Guest changes waiting', get_the_title( $guest_id ) . ' changed: ' . implode( ', ', array_keys( $pending['fields'] ) ) );
}, 10, 2 );

// Offer two blank social rows instead of three.
add_filter( 'benecaster_guest_manager_guest_form_data', static function ( array $form ): array {
    if ( 'form' === $form['state'] ) {
        $form['blank_rows'] = 2;
    }
    return $form;
} );

View on GitHub →

Hooks Used

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