Skip to content
Custom fields for WordPress that are quick to build and quick to load. Get Pro
Docs

Hooks and filters

Other

1 minute to read Updated 1 week ago

On this page

ugly_client_ip

Filter. The address of the visitor, used to limit tries. For a proxy, the constant UGLY_FIELDS_PROXY_HEADER is usually enough.

PHP
add_filter( 'ugly_client_ip', function ( $ip ) {
	return isset( $_SERVER['HTTP_X_REAL_IP'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ) : $ip;
} );

ugly_show_upgrade

Filter. In the free version, the Upgrade button of the menu. Return false to hide it (for example on a client site that you manage).

PHP
add_filter( 'ugly_show_upgrade', '__return_false' );

ugly_preview_on_site

Filter. When you press Preview on a post, the public page shows the values you typed in the editor before saving them (they are kept in the autosave of the person previewing). This filter says whether that is allowed on the current request.

Receives bool. By default true on the public side of the site and false inside the admin
Return true to use the unsaved values in the preview, false to show the saved ones

You almost never need it. It exists so that code running inside the admin (a test, or a tool that renders a preview from there) can ask for the same behavior.

PHP
// Never show unsaved values in a preview, on any request.
add_filter( 'ugly_preview_on_site', '__return_false' );

Did this article answer your question?