Description
This shortcode reads a value from the $_SERVER superglobal and displays it on the page. It is commonly used to access server and request environment information such as the visitor’s IP address, user agent, or the current page URL.
Shortcode Examples
Display the visitor’s IP address:
[memb_server name="REMOTE_ADDR"]
Show the referring page:
[memb_server name="HTTP_REFERER" default="Direct visit"]
Display the current request method:
[memb_server name="REQUEST_METHOD"]
Apply text formatting to the output:
[memb_server name="HTTP_USER_AGENT" txtfmt="htmlspecialchars"]
Shortcode Parameters
name | (Required) Comma-delimited list of keys to look up in the $_SERVER variable. |
|---|---|
default | The default value to use if the key is empty. Defaults to an empty string. |
txtfmt | (Optional) Comma-delimited list of text processing functions to apply to the output. |
capture | Captures the shortcode output and routes it to a variable for later use. |
before | Text to display before the output value. |
after | Text to display after the output value. |
htmlattr | If set, outputs the value as an HTML attribute rather than as visible text. |
Additional Information
Using [memb_server] with no parameters displays all $_SERVER variables for debugging purposes. Commonly useful keys include REMOTE_ADDR (visitor IP), HTTP_USER_AGENT (browser), REQUEST_URI (current path), HTTP_REFERER (referring URL), and SERVER_NAME (host name).
Shortcode Attributes
| Conditional | No |
|---|---|
| Nestable | No |
| Accepts formatting | Yes |
| Capturable | Yes |