WordPress plugin works only for logged users

I’m using Dave’s WordPress Live Search.

The problem I have, is live search – it works only for logged users. If i’m logged in, plugin works fine. I found this line:

Read More
'ajaxURL' => admin_url('admin-ajax.php', is_ssl()),

which mean plugin is using admin-ajax.php and i think unlogged users haven’t access to it.
I tried to define ajaxURL without , is_ssl():

'ajaxURL' => admin_url('admin-ajax.php'),

but didn’t help.

Is it a problem with access to wp-admin/admin-ajax.php? How can i change it?

Related posts

Leave a Reply

2 comments

  1. This is old, but I was looking into this.
    Rather than changing the core, you can duplicate the hooks of the plugin and add ”no_priv” versions. I am sure this is more elegant than duplicating a file in the core.

    See: http://codex.wordpress.org/AJAX_in_Plugins

    From that page:

    “Ajax on the Viewer-Facing Side
    As of WordPress 2.8, there is a new hook similar to ‘wp_ajax_my_action’:

    ‘wp_ajax_nopriv_my_action’ executes for users that are not logged in.
    So, if you want it to fire for both visitors and logged-in users, you can do this:

    add_action('wp_ajax_my_action', 'my_action_callback');
    add_action('wp_ajax_nopriv_my_action', 'my_action_callback');"
    
  2. In your case I would clone admin-ajax.php and rename it and remove all admin related conditionals from the file.

    More specific:

    • Make sure to include the new cloned file where required instead of
      the old one.
    • Make sure also you are changing only the permissions
      levels from the file.
    • The cloned file just put in the same directory as it is the admin-ajax.php, “wp-admin”

    Good luck! 🙂