Skip to content
🚀 Rapid Application Development with the App Builder

app.userHasRole(role)

Checks if the currently logged-in user has the specified role.

Scope: GLOBAL

Parameters

ParameterTypeDescription
rolestringAny WordPress role.

Return Value

TypeDescription
trueIf the currently logged-in user has the specified role.
falseOtherwise.

✨ Example

js
if (!app.userHasRole("manager")) {
    app.setGlobalSearch(false)
    app.setColumnFilters(false)
    app.setInsert(false)
    app.setUpdate(false)
    app.setDelete(false)
    app.setInlineEditing({
        "email": false,
        "first_name": true,
        "last_name": true,
    })
    app.setBulkActions({
        "pdf": true,
        "xml": false,
        "delete": false,
    })
}

Notes

Please be aware that the server will block any rights that surpass the app's configured limitations, even though permissions can be dynamically granted or revoked.