• I would like to change the ‘cheating are we?’ message that appears when a team member is trying to access an area of the website they do not have permission to access. I can see this topic has been posted before but I can’t see a resolution that doesn’t involve winding the WordPress version back. Cheers.

Viewing 1 replies (of 1 total)
  • Moderator cubecolour

    (@numeeja)

    This can be changed with a simple custom plugin to override translatable strings

    As an example, you can try this:

    
    <?php
    /*
    Plugin Name: No Cheating
    Plugin URI: http://cubecolour.co.uk
    Description: Change the 'Cheatin' huh?' message
    Author: cubecolour
    Version: 0.0.1
    Author URI: http://cubecolour.co.uk
    Text Domain: no-cheating
    
    Licence: GPL
    
    */
    
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    /**
     * No Cheating
     *
     */
    function ccnc_filter_gettext( $translated, $original, $domain ) {
    
        // Array of original & replacement strings
        $strings = array(
            "Cheatin’ uh?" => "Computer says no",
        );
    
    	// Replace the translation with the new string
        if ( ! empty( $strings[$original] ) ) {
            $translations = get_translations_for_domain( $domain );
            $translated = $translations->translate( $strings[$original] );
        }
    
        return $translated;
    }
    add_filter( 'gettext', 'ccnc_filter_gettext', 10, 3 );
    

    Change the example “Computer says no” text to whatever you want to be returned in place of the “Cheatin’ uh?” message.

    Note that Cheatin’ uh? is used as that is the orginal string in WordPress being translated to “Cheating are we?” in your localised version.

    Also ensure that the apostrophe in the Cheatin’ uh? entry in the $strings array is replaced with the HTML character code &#8217; as pasting the character code into the forum code block above turned it into an apostrophe.

    Other strings can also be replaced by adding them to the $strings array.

    • This reply was modified 8 years, 10 months ago by cubecolour.
    • This reply was modified 8 years, 10 months ago by cubecolour. Reason: fix html code for apostrophe being shown as apostrophe
Viewing 1 replies (of 1 total)

The topic ‘Cheating are we?’ is closed to new replies.