# desktop-mode/1.1.12/apps/user-edit/parts/permissions.php

OpenStation: Desktop Windows, Dock &amp; Virtual Desktops for WP Admin, version 1.1.12. 57 lines.

- Page: https://pluginprobe.com/plugins/desktop-mode/1.1.12/code/apps/user-edit/parts/permissions.php
- Raw: https://pluginprobe.com/plugins/desktop-mode/1.1.12/raw/apps/user-edit/parts/permissions.php
- Modified: 2026-09-04T15:30:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/desktop-mode/1.1.12/code/apps/user-edit/parts/permissions.php#L10-L20`.

```php
<?php
/**
 * User Edit app — capability gates.
 *
 * The window is registered for ANY logged-in user (everyone has a
 * profile they can edit). Per-target capability is re-checked at
 * REST time — saving uses core's `/wp/v2/users/<id>` PUT, which
 * already enforces `edit_user, $id`; the routes in `rest.php` apply
 * the same check before returning data.
 *
 * @package OpenStation
 */

defined( 'ABSPATH' ) || exit;

/**
 * Whether the user is eligible to have the User Edit window registered.
 *
 * Defaults to `true` for any logged-in user. Returning `false` from
 * the filter disables registration entirely, which falls back to the
 * classic `user-edit.php` / `profile.php` iframe path.
 *
 * @param int|null $user_id Optional. Defaults to `get_current_user_id()`.
 * @return bool
 */
function openstation_user_edit_window_user_can_register( $user_id = null ) {
	$user_id = null === $user_id ? get_current_user_id() : (int) $user_id;
	$can     = $user_id > 0;

	/**
	 * Filter whether the current user can have the User Edit window
	 * registered.
	 *
	 * @param bool $can     Default: any logged-in user.
	 * @param int  $user_id User being checked.
	 */
	return (bool) apply_filters( 'openstation_user_edit_window_user_can_register', $can, $user_id );
}

/**
 * Whether `$viewer_id` may edit `$target_id`'s profile. Server-side
 * canonical check used by the routes and any plugin code that wants
 * to mirror the gating.
 *
 * @param int $viewer_id Viewer.
 * @param int $target_id Target.
 * @return bool
 */
function openstation_user_edit_window_can_edit( $viewer_id, $target_id ) {
	$viewer_id = (int) $viewer_id;
	$target_id = (int) $target_id;
	if ( $viewer_id <= 0 || $target_id <= 0 ) {
		return false;
	}
	return (bool) user_can( $viewer_id, 'edit_user', $target_id );
}

```
