apply_filters( ‘admin_url’, string $url, string $path, int|null $blog_id, string|null $scheme )

Filters the admin area URL.

Parameters

$urlstring
The complete admin area URL including scheme and path.
$pathstring
Path relative to the admin area URL. Blank string if no path is specified.
$blog_idint|null
Site ID, or null for the current site.
$schemestring|null
The scheme to use. Accepts 'http', 'https', 'admin', or null. Default 'admin', which obeys force_ssl_admin() and is_ssl() .

Source

return apply_filters( 'admin_url', $url, $path, $blog_id, $scheme );

Changelog

VersionDescription
5.8.0The $scheme parameter was added.
2.8.0Introduced.

User Contributed Notes

  1. Skip to note 2 content
    function wpdocs_advanced_custom_admin_url( $url, $path ) {
        // Check if the current user is an administrator
        if ( current_user_can( 'administrator' ) ) {
            // Check if the user is accessing the plugins page
            if ( strpos( $path, 'plugins.php' ) !== false ) {
                // Add a different custom query parameter
                $url = add_query_arg( 'plugins_param', 'value', $url );
            } else {
                // Add the default custom query parameter
                $url = add_query_arg( 'custom_param', 'value', $url );
            }
        }
    
        return $url;
    }
    add_filter( 'admin_url', 'wpdocs_advanced_custom_admin_url', 10, 2 );

You must log in before being able to contribute a note or feedback.