WordPress.org

Ready to get started?Download WordPress

Forums

Ajax for subscribers not working (2 posts)

  1. howitzer
    Member
    Posted 1 year ago #

    I have a very simple AJAX function that works fine when logged in as admin, but when logged in as a subscriber the call to admin-ajax.php returns a html page with the header and footer of my theme, and that's it.

    By doing some wolf fencing I've tracked it down to line 37 of admin-ajax.php do_action( 'admin_init' );. It gets there and just returns rubbish.

  2. Chiangmaiplaces
    Member
    Posted 1 year ago #

    I have exactly the same problem.

    Working on wordpress 3.5.1 and my ajax request works well when logged in as an admin user (or contributor) and when not logged in.
    When logged in with a subscriber account, my ajax request returns the homepage content, which is obviously not what I want...

    Here is my code to create the ajax actions:

    add_action('wp_ajax_nopriv_subscribe_magazine', array(&$this, 'actionSubscribeMagazine') );
    add_action('wp_ajax_subscribe_magazine', array(&$this, 'actionSubscribeMagazine') );

    and my action function:

    public function actionSubscribeMagazine() {
     if ( empty( $_GET['idmag'] ) || ! is_user_logged_in() ) {
    			die( __( 'Sorry, we could not understand your request.' ) );
    		}
     // ...
    }

    This action is never called when logged in as a subscriber.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags