Tagged: shortcode
-
AuthorPosts
-
June 2, 2020 at 10:58 pm #1218868
Hi,
I became aware that the maps integrated via the plugin maps marker pro are not loading anymore. The following error is shown:
“Error: the map with ID 1 could not be loaded. Please contact the site owner.”
the developer console is showing this error: “[Maps Marker Pro] Error loading settings (SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data)”
When I am logged in as a WP admin then the maps load as intended.
Do you know how to fix the error?
best regards, Peter
June 3, 2020 at 12:46 pm #1219027Hi,
UPDATE:
I also asked the plugin developers about the issue. They say:
“you site is redirecting admin-ajax.php to the home page. I assume this is from a security plugin and doesn’t happen for logged-in users. Maps Marker Pro requires admin-ajax.php to work. Please disable this feature.”
I have then investigated the error further and I think I found the problem. In my child theme functions.php, I have included the following function because I don’t want website subscribers to access the WP backend at all.
// redirect back to homepage and not allow access to wp backend for subscribers function rkk_redirect_admin(){ if ( ! current_user_can( 'edit_posts' ) ){ wp_redirect( site_url() ); exit; } } add_action( 'admin_init', 'rkk_redirect_admin' );
When commenting the function out the map loads for not logged in users, as intended. My understanding of WP developing and PHP is limited. What exactly is the problem with this function? How to adjust it in order to achieve subscribers not having access to WP backend and not cause the maps marker pro error?
Best regards, Peter
June 3, 2020 at 6:44 pm #1219224UPDATE:
I have changed the if statement to the following:
// redirect back to homepage and not allow access to wp backend for subscribers function rkk_redirect_admin(){ if ( ! wp_doing_ajax() && ! current_user_can( 'edit_posts' ) ) { wp_redirect( site_url() ); exit; } } add_action( 'admin_init', 'rkk_redirect_admin' );
Now it doesn`t fire when admin_ajax.php is called. Is this a robust solution? Do you see any problems with this?
Best regards, Peter
June 10, 2020 at 5:21 pm #1221273Hi,
Thank you for the update. This should be fine as long as you’re using an admin account or a user that can edit posts — else will be redirected to the home page.
Best regards,
IsmaelJune 10, 2020 at 5:47 pm #1221283Hi Ismael,
thank you for your answer. I have no further questions on this issue.
Please do have a look at my other open support requests, as I am hoping to make progress with the site.
Best regards, Peter
June 12, 2020 at 1:27 pm #1222040 -
AuthorPosts
- The topic ‘Maps Marker Pro Maps not loading’ is closed to new replies.