So, i managed to achieve what i want by directing the exisiting window.location.href to a newly created php file i put in the root called .login.php. I will share the code below as it handles the user roles nicely when logging in using this jquery method
.login.php
<?php
require_once('wp-load.php');
function user_role_check_modal( $role, $user_id = null ) {
$user = wp_get_current_user();
if ( empty( $user ) )
return false;
return in_array( $role, (array) $user->roles );
}
if ( user_role_check_modal( 'administrator' )):
header("Location: /wp-admin/");
exit();
endif;
if ( user_role_check_modal( 'customer' )):
header("Location: /my-account/");
exit();
else:
header("Location: /my-account/");
exit();
endif;
Hope this helps someone who maybe in the future needs work around
Related Posts:
- Adding “Remember Me” in custom login
- username_exists() function can’t be access without logging in
- How build a custom login/register form with error handling?
- PHP – redirect https to http and www to non-www
- Change the footer text on the login page
- Redirect to Page after Post Submit
- Can i check if user is doing any ajax request?
- How to redirect users to custom lostpassword page?
- How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
- How to add default images into theme customizer image control?
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Constructing a custom login form using ajax
- Validate a users email address when using gmail to register
- Logout and redirect using the WP Menu
- Click loads template via ajax
- Change links automatically to affiliate links
- How to speed up admin-ajax.php in wordpress
- PHP If user is logged in & on home page redirect
- get post based on category chosen in drop down – The ajax method
- Login/logout in header
- How to store data from multiple forms using ajax and php
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- Why ajax doesn’t work on certain wordpress hooks?
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- dynamic dependent select dropdown
- getting logged in user info (wp-load.php) from parent directory
- how to make custom ajax handler?
- Problem with login form
- How to disable controls in theme customizer?
- Log in / Log Out Custom Button
- How to redirect users based on role and content of redirect_to?
- Moving code from theme header to functions.php
- How to display login form anywhere, when user isn’t logged in, without redirecting?
- is_user_logged_in() not working in AJAX validation call
- Using data sent via AJAX in multiple functions on a WP plugin
- Function won’t run onclick using Ajax
- WordPress redirect redirecting too many times or not at all
- Simple AJAX notification when the new post is added to the database
- Why i can’t get custom fields value or post ID via Ajax?
- Post not populating for custom post type based on category selection
- How to get post category list as select in front-end?
- Is there a hack for using is_page() within the function.php file?
- Execute Jquery when a specific page in my plugin is loading
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- AJAX function not working [closed]
- WP insert post Redirect after function has executed
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Disclaimer that will show every refresh of the page
- Database entry removed on browser refresh, Ajax PHP jQuery
- Can’t log in to WordPress wp-admin after adding code to functions.php
- Store ajax data in PHP variable
- Multiple AJAX handler functions conflict in functions.php
- Ajax filter with loadmore button
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- register_block_type is not working properly
- get_the_author_meta( ‘ID’ ) just return 1
- Update $wpdb query with AJAX
- Restrict wordpress access to logged users only
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Infinite loop when logging out using custom login form
- Menu not updating for logged in users after redirect
- how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
- Refresh page after login with litespeed cache
- WordPress Ajax filter: Create two loops for different output styles?
- Offset with ajax load more posts duplicates
- ajaxurl usage for a custom function
- How to call a function from functions.php with ajax?
- wp-login.php?redirect_to=https problem
- is_user_logged_in() not working in homepage
- Custom Post type Ajax search results
- Find the method which AJAX GET calls
- AJAX Returning Way Too Many Posts
- redirect 301 with special character like WIX site “#!”
- wordpress ajax return 0
- Submitting my form to the database and then redirecting to payment site
- wp_delete_comment is doing nothing
- Modify category archive page loop on functions.php
- Registration form not registering First and Last name
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- Redirect users not logged in to the standard login page (and back) from some posts and pages
- ajax form function error
- Link to external page has wordpress blog-url inside
- AJAX: WordPress filters inside $html do not work as intended
- wp_login_url always redirects me to wp-admin
- wp-login – unable to redirect user to a custom login url
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- How can I display a Divi content inside a modal based on an AJAX request
- Redirect to current URL and append specified URL parameter on unsuccessful login through Elementor login form widget
- Processing data and redirecting with query string
- Removing unneccessary p-tags (Not every p)
- How to remove the excerpt in the Dzonia Lite theme
- comments_number display outside specified span
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Set WordPress Default Template
- Recovering WP Login Credintials in Code?
- Shortcode content filter?
- How to run JS, PHP and etc. inside WP post?