Friday, August 12, 2022
HomeWordPress Developmentwp-ajax error 500 or Wordpress subdomain (similar theme) would not entry to...

wp-ajax error 500 or WordPress subdomain (similar theme) would not entry to wp-admin folder from plugin


I take advantage of subdomain on the identical theme of predominant area, growing a plugin, this one cannot entry to js file from a subdomain.
To make use of subdomains with the identical theme of area I take advantage of that:

change ( $_SERVER['HTTP_HOST'] ) {
case 'sub1.web site.com':
    outline( 'WP_HOME', 'https://sub1.web site.com/' );
    break;
case 'sub2.web site.com':
    outline( 'WP_HOME', 'https://sub2.web site.com/' );
    break;
case 'sub3.web site.com':
    outline( 'WP_HOME', 'https://sub3.web site.com/' );
    break;
default:
    outline( 'WP_HOME', 'https://area.com/' );
}
outline('WP_SITEURL', WP_HOME);

outline('ADMIN_COOKIE_PATH', '/wp-admin');
outline('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
outline('COOKIEPATH', $_SERVER['HTTP_HOST']);
outline('SITECOOKIEPATH', $_SERVER['HTTP_HOST']);
outline('COOKIEHASH', md5('area.com') );

Once I use wp_localize_script('ajax', 'wpAjax', array('ajaxUrl' => admin_url('admin-ajax.php')));
admin-ajax.php is not discovered and I get error 500 as a result of it’s known as from https://sub1.web site.com/wp-admin/admin-ajax.php (show in console) and never web site.com/wp-admin/admin-ajax.php.

If I attempt to overwrite admin_url as :wp_localize_script('ajax', 'wpAjax', array('ajaxUrl' => 'https://web site.com/wp-admin/admin-ajax.php')); nothing change

the js name :

var formdata = $('#LogAtv').serialize();
formdata += '&motion=atv_user_login&log-param=login_data';

$.ajax({ 
            url:wpAjax.ajaxUrl,
            information:formdata,
            sort:'POST',
            dataType: 'json',
            success:perform(response){

Should I outline different factor to permit subdomains to entry wp-admin and js file from plugin ?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments