// लॉगिन पेज रीडायरेक्ट
add_action('init', function() {
$login_page = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if (strpos($login_page, 'wp-login.php') !== false && !is_user_logged_in()) {
wp_redirect(home_url('/404'));
exit();
}
if (is_admin() && !is_user_logged_in()) {
wp_redirect(home_url('/404'));
exit();
}
});
// नए लॉगिन URL के लिए हुक
add_filter('site_url', function($url, $path, $scheme, $blog_id) {
if ($path === 'wp-login.php') {
return home_url('/my-login'); // अपना कस्टम URL डालें
}
return $url;
}, 10, 4);
// लॉगिन प्रयासों को ट्रैक करने के लिए
add_action('wp_login_failed', 'track_login_attempts');
function track_login_attempts($username) {
$attempts = get_transient('login_attempts_' . $_SERVER['REMOTE_ADDR']) ?: 0;
$attempts++;
set_transient('login_attempts_' . $_SERVER['REMOTE_ADDR'], $attempts, HOUR_IN_SECONDS); // 1 घंटे के लिए ब्लॉक
}
// लॉगिन प्रयासों को वैलिडेट करें
add_filter('authenticate', 'validate_login_attempts', 30, 3);
function validate_login_attempts($user, $username, $password) {
$attempts = get_transient('login_attempts_' . $_SERVER['REMOTE_ADDR']);
if ($attempts >= 3) {
return new WP_Error(
'too_many_attempts',
'त्रुटि: 3 गलत प्रयासों के बाद आपको 1 घंटे के लिए ब्लॉक कर दिया गया है।'
);
}
return $user;
}
// सफल लॉगिन पर अटेम्प्ट्स रीसेट करें
add_action('wp_login', 'reset_login_attempts');
function reset_login_attempts() {
delete_transient('login_attempts_' . $_SERVER['REMOTE_ADDR']);
}
Warning: Cannot modify header information - headers already sent by (output started at /home2/bmys/public_html/wp-content/themes/astra/functions.php:1) in /home2/bmys/public_html/wp-includes/sitemaps/class-wp-sitemaps-renderer.php on line 126
https://bmys.in/wp-sitemap-posts-post-1.xmlhttps://bmys.in/wp-sitemap-posts-page-1.xmlhttps://bmys.in/wp-sitemap-posts-elementor-hf-1.xmlhttps://bmys.in/wp-sitemap-taxonomies-category-1.xmlhttps://bmys.in/wp-sitemap-users-1.xml