Disable the “remember me” to wp-admin

You can do it with JavaScript (jQuery) or outputbuffering. A combination of both (outputbuffering and JS) are in the script below.

PHP:

namespace WPSE77581;

add_action( 'plugins_loaded', 'WPSE77581\remove_forgetmenot', 10, 0 );

function remove_forgetmenot() {

    add_action( 'login_enqueue_scripts', 'WPSE77581\enqueue_script', 10, 0 );

    add_action( 'login_head', 'WPSE77581\start_outputbuffer', 1, 0 );
    add_action( 'login_footer', 'WPSE77581\end_outputbuffer', 1, 0 );

}

function enqueue_script() {

    wp_enqueue_script(
        'WPSE77581-remove-forgetmenot',
        plugins_url( 'wpse77581.js', __FILE__ ),
        array( 'jquery' ),
        false,
        true
    );

}

function start_outputbuffer() {

    ob_start();

}

function end_outputbuffer() {

    $html = ob_get_clean();

    $search="#<p class="forgetmenot">.+</p>#Uuis";

    $html = preg_replace( $search, '', $html );

    echo $html;

}

JS [wpse77581.js]:

jQuery( document ).ready(
    function ( $ ) {
        $( '.forgetmenot' ).remove();
    }
);

Both solutions has it’s assets and drawbacks. Using outputbuffering can be a bit tricky if other plugins use outputbuffering too. JavaScript can be disabled in the visitors browser. Outputbuffering manipulate the DOM before it is send to the browser, JS after it was send to the browser.

Update

Why does the plugin code does not work in my functions.php?

To answer this question, we have to take a closer look at the hooks and have to understand when and what happened while WordPress is loading. At first the working code for the functions.php

<?php

/**
 * Remove forgetmenot-checkbox on login screen
 * Uses the hook 'after_theme_setup' instead of 'plugins_loaded' because
 * first the theme have to be setup for get_template_directory_uri()
 *
 * @uses add_action()
 * @hook after_setup_theme
 */
add_action(
    'after_setup_theme',
    'WPSE77581_remove_forgetmenot',
    10,
    0
);

/**
 * Hook up all actions and filters
 *
 * @uses add_action()
 * @hook login_enqueue_scripts
 * @hook login_head
 * @hook login_footer
 */
function WPSE77581_remove_forgetmenot() {

    // add JavaScript
    add_action( 'login_enqueue_scripts', 'WPSE77581_enqueue_script', 10, 0 );

    // plain PHP with outputbuffering
    add_action( 'login_head', 'WPSE77581_start_outputbuffer', 1, 0 );
    add_action( 'login_footer', 'WPSE77581_end_outputbuffer', 1, 0 );

}

/**
 * Enqueueing needed JavaScripts
 * JS is stored in the folder 'js' inside the theme folder
 *
 * @uses wp_enqueue_script
 * @uses get_template_directory_uri()
 */
function WPSE77581_enqueue_script() {

    wp_enqueue_script(
        'WPSE77581-remove-forgetmenot',
        get_template_directory_uri() . '/js/wpse77581.js',
        array( 'jquery' ),
        false,
        true
    );

}

/**
 * Start outputbuffering
 * Buffers the DOM for later manipulation
 */
function WPSE77581_start_outputbuffer() {

    ob_start();

}

/**
 * End outputbuffering
 * Get the content from outputbuffer and remove the paragraph with checkbox
 */
function WPSE77581_end_outputbuffer() {

    $html = ob_get_clean();

    $search="#<p class="forgetmenot">.+</p>#Uuis";

    $html = preg_replace( $search, '', $html );

    echo $html;

}

Where are the differences to the plugin code? At first it is no longer a plugin and so we can not use plugins_url() to get the uri to the JavaScript. After a search in the Codex, we find the function [get_template_directory_uri()][1] to get the correct path to the JavaScript file.

After simply changing from plugins_url() to get_template_directory_uri() the code does not work. Now we have to start thinking. The code is no longer a plugin code, it is now a ‘theme’ or ‘template’ code. Can we use the hook plugins_loaded for a theme code?

It seems that this is not a good idea. To understand why this is not a good idea, we have a look inside the core files (in this case take wp-settings.php). As we read the core files, we find the line with do_action('plugins_loaded');. Until this point, no theme was setup and so get_template_directory_uri() does not know anything about a template directory.
Continue reading the core file, we will find the part where the theme is setup. And we also find a line with do_action('after_setup_theme');. This seems to be a good point to hook up our code. After replacing plugins_loaded with after_setup_theme and test the code, we see the code will work.

If you want to develop plugins and / or themes for WordPress, you need to understand when and what happened while WordPress is loaded! If you get stuck, take a brief minute and start reading the core files.

Happy new year.

tech