Last active
July 1, 2024 00:11
-
-
Save gene1wood/f3d39a8f894973cc8d75e2a632ec3715 to your computer and use it in GitHub Desktop.
Disable Wordpress native username password login when using Google Apps Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Disable Native Login | |
* Plugin URI: https://cs.cementhorizon.com/ | |
* Description: Disable the native username password login in wordpress | |
* Version: 1.0.0 | |
* Author: Gene Wood | |
* Author URI: https://cs.cementhorizon.com/ | |
* License: GPL2 | |
*/ | |
// Install this by putting it in wp-content/plugins/disable-native-login/ | |
// https://deluxeblogtips.com/completely-disable-login-username-password-wordpress/ | |
add_action( 'login_init', function () { | |
if ( isset( $_POST['log'] ) || isset( $_POST['user_login'] ) ) { | |
die; | |
} | |
} ); | |
// https://codex.wordpress.org/Customizing_the_Login_Form | |
function hide_login_form() { ?> | |
<style type="text/css"> | |
#loginform h3.galogin-or, #loginform p:not(.galogin), #loginform div.user-pass-wrap, #login p#nav { | |
display: none; | |
} | |
</style> | |
<?php } | |
add_action( 'login_enqueue_scripts', 'hide_login_form' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for this. perfect for me as I only want users to login via my social button (patreon).
But, I wanted a URL override to display the old form based on Query string. I am a Microsoft.Net programmer so not an expert in Wordpres dev or PHP but pieced this together. If you like and want to incorporate it in but have a cleaner implementation... feel free to modify
Simply adding a query parameter "&localadmin" will display the original fields and allow login the classic way. obviously that localadmin can be adjusted. :-)