Custom Gmail SMTP

// Custom Gmail SMTP / Kiri Vadivelu / 2026 add_action(‘phpmailer_init’, ‘send_gmail_smtp’); function send_gmail_smtp($phpmailer) { $phpmailer->isSMTP(); $phpmailer->Host = ‘smtp.gmail.com’; $phpmailer->SMTPAuth = true; $phpmailer->Port = 587; // Use 465 for SSL, 587 for TLS $phpmailer->SMTPSecure = ‘tls’; // ‘ssl’ for port 465…Continue reading

Debug Load Email

// Debug Load Email / Kiri Vadivelu / 2026 add_action( ‘template_redirect’, ‘page_load_email’ ); function page_load_email() { $to = “[email protected]”; // Replace with your email $subject = ‘wp_mail function test’; $message = ‘This is a test of the wp_mail function: wp_mail…Continue reading

Page Load Email

// Page Load Email / Kiri Vadivelu / 2026 add_action( ‘template_redirect’, ‘page_load_email’ ); function page_load_email() { // Only on the front end page load $to = ‘[email protected]’; // Replace with your email $subject = ‘Page Load Email Test’; $message =…Continue reading

Change From Email

// Change From Email / Kiri Vadivelu / 2026 add_filter( ‘wp_mail_from’, function ( $old ) { return ‘[email protected]’; // Replace with your email } ); add_filter( ‘wp_mail_from_name’, function ( $old ) { return ‘Super Dev’; // Replace with your name…Continue reading

List All URLs

// List All URLs / Kiri Vadivelu / 2026 add_action(‘admin_menu’, ‘add_url_list_page’); function add_url_list_page() { add_management_page(‘All URLs’, ‘All URLs’, ‘manage_options’, ‘all-urls’, ‘display_all_urls’); } function display_all_urls() { $args = array( ‘post_type’ => array(‘post’, ‘page’), ‘post_status’ => ‘publish’, ‘numberposts’ => -1 ); $posts…Continue reading

Custom Role Redirect

// Custom Role Redirect / Kiri Vadivelu / 2026 function custom_role_dashboard() { // Replace ‘contractor’ with your actual custom role slug $restricted_role = ‘contractor’; if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) { $current_user = wp_get_current_user(); // Check if…Continue reading

Restrict Role Access

// Restrict Role Access / Kiri Vadivelu / 2026 function restrict_role_access() { // Check if user is trying to access admin area if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) { $user = wp_get_current_user(); // Check for Subscriber or…Continue reading

Open external links in new tab

document.addEventListener(“DOMContentLoaded”, function() { var links = document.querySelectorAll(“a[href]”); links.forEach(function(link) { if (link.hostname !== window.location.hostname) { link.setAttribute(“target”, “_blank”); link.setAttribute(“rel”, “noopener noreferrer”); } }); });Continue reading

Auto Admin Logout

// Auto Admin Logout / Kiri Vadivelu / 2026 add_filter( ‘auth_cookie_expiration’, ‘short_session_admin’, 10, 3 ); function short_session_admin( $expiration, $user_id, $remember ) { // Only apply the short timeout for administrators if ( user_can( $user_id, ‘manage_options’ ) ) { return 3600;…Continue reading