Untitled
unknown
plain_text
6 months ago
915 B
14
Indexable
// Custom 404 handler for agent dashboard URLs
add_action('template_redirect', function() {
if (is_404()) {
$current_url = $_SERVER['REQUEST_URI'];
// Check if this is an agent dashboard URL
$pageid = apply_filters('wpml_object_id', get_option('salesking_agents_page_setting', 'disabled'), 'post', true);
$slug = get_post_field('post_name', $pageid);
if (strpos($current_url, '/'.$slug.'/') !== false) {
// This is an agent dashboard URL showing a 404
// Force a reload using JavaScript
echo '<script>
if (window.sessionStorage.getItem("reloaded_' . md5($current_url) . '") !== "true") {
window.sessionStorage.setItem("reloaded_' . md5($current_url) . '", "true");
window.location.reload();
}
</script>';
exit;
}
}
});Editor is loading...
Leave a Comment