Skip to main content

Metabox

Vasyl MartyniukLess than 1 minute

Syntax

Metabox:<metabox-internal-id>

Definition

Metaboxes are small functional blocks that typically render on the post-edit screen and identifies by the unique internal ID.

To ensure the uniqueness of the metabox ID, AAM compiles it by combining the screen name and ID assigned to metabox during registration (for more info, refer to the add_meta_boxopen in new window WordPress core function). With AAM UI you can easily get the metabox ID on the "Metaboxes & Widgets" tab.

Metabox Widget ID

Note!

AAM only removes metaboxes from the UI. It does not take into consideration the functionality that facilitates those metaboxes. This means that the end-users may reverse engineer the way your website is set up and submit data that hidden metaboxes capture.

Below is an example of the statement that removes the "Excerpt" metabox on the backend side when a user comes from a specific IP range. We explicitly typecast IP addresses in the condition to (*ip), so AAM can correctly compute that user's IP address is indeed within defined IP range.

{
    "Statement": [
        {
            "Effect": "deny",
            "Resource": "Metabox:post|postexcerpt",
            "Condition": {
                "Between": {
                    "(*ip)${USER.ip}": [
                        "(*ip)10.0.0.0",
                        "(*ip)10.255.255.255"
                    ]
                }
            }
        }
    ]
}

The premium Complete Package also adds the ability to use the wildcard * denotation to target all metaboxes. For example in the statement below, we restrict access to all the metaboxes on all post-edit screens except the "Publish".

{
    "Statement": [
        {
            "Effect": "deny",
            "Resource": "Metabox:*"
        },
        {
            "Effect": "allow",
            "Resource": "Metabox:post|submitdiv"
        }
    ]
}