This sample manages WordPress users through the REST API using HTTP Basic authentication. It is a straightforward API example for environments where the site exposes authenticated REST endpoints for user administration.
Platform Script: WordPressHttp.json
WordPress user accounts exposed through the WordPress REST API.
| Operation | Description |
|---|---|
CheckSystem |
Uses the service account to call the REST API settings endpoint and verify connectivity and privileges. |
CheckPassword |
Uses the managed account credentials with Basic auth to call /users/me/ and confirm the password works. |
ChangePassword |
Uses the service account to enumerate users, locate the target user, and post a new password to that user's REST endpoint. |
- A WordPress site reachable from SPP with the REST API enabled
- The JSON Basic Authentication plugin (or equivalent Basic-auth support) installed on the site
- A service account with permission to read settings and update WordPress users; use HTTPS because Basic auth sends credentials on every request
- Upload the script:
Import-SafeguardCustomPlatformScript -FilePath ./WordPressHttp.json - Create a custom platform using this script
- Create an asset using the platform
- Configure service account, managed account(s), and the
APIURLpath for the site's REST API - Test with
Test-SafeguardAssetAccountPassword -ExtendedLogging
The script chooses HTTP or HTTPS from UseSsl, builds a request object, and attaches Basic authentication. CheckSystem calls %APIURL%/settings, while CheckPassword calls %APIURL%/users/me/ with the managed account's credentials. For password changes it first calls %APIURL%/users?per_page=100, finds the matching user, then posts a JSON body containing the new password to that user's endpoint and interprets the returned HTTP status.
APIURL: Required REST path below the site root, such aswp-json/wp/v2.UseSsl: Uses HTTPS whentrue; strongly recommended for production.SkipServerCertValidation: Ignores certificate validation errors when enabled.
- This sample requires Basic-auth support on the WordPress REST API; stock WordPress does not enable this by default.
ChangePasswordonly searches the first100users because the sample usesper_page=100.- User lookup in
ChangePasswordcompares the configured account name to thenamefield returned by the API, so the Safeguard account name must match that value.