Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buttons + Tabs Loading Whole Site Into Template


  • Andrew Tibbetts
    Participant

    @andrewgtibbetts

    When I click on certain buttons and tabs (ones that I assume are doing some ajax work) it loads the entire home page into the template (duplicating header, footer, etc).

    Example:
    Go to “Groups” page (default on “All Groups” tab) and click the “My Groups” tab.
    Content will fade out as if about to ajax in the “My Groups” content but instead the entire home page will replace the content of #groups-dir-list.
    Any idea?

Viewing 6 replies - 1 through 6 (of 6 total)

  • Andrew Tibbetts
    Participant

    @andrewgtibbetts

    Ok, I’ve found that it is tied to my redirect function mentioned in https://buddypress.org/support/topic/only-administrator-can-change-avatar/. I’ll repeat it here for posterity:

    // keep the 'normies' out of the admin
    add_action( 'admin_init', 'custom_admin_init', 1 );
    function custom_admin_init() {
    
    	if ( is_user_logged_in() && ! current_user_can( 'administrator' ) ) {
    
    		wp_redirect( home_url() ); die();
    	}
    }

    Seems like some (ajax?) content population requires accessing the admin in someway.
    So, how to keep everyone except admins out of the admin area but still allow all this content stuff to be uninterrupted?


    shanebp
    Moderator

    @shanebp

    Try:

    function andrew_admin_access() { 
    
       if ( is_admin() && ! is_super_admin() ) {
          wp_redirect( home_url() ); 
          exit;
       }
    
    }
    add_action( 'wp', 'andrew_admin_access' );

    Andrew Tibbetts
    Participant

    @andrewgtibbetts

    Switching the action to wp causes a redirect loop.
    But we’re thinking it’s just a matter of finding the right action to hook into?


    Andrew Tibbetts
    Participant

    @andrewgtibbetts

    Sorry, correction:
    This doesn’t cause a redirect loop…but it doesn’t prevent access of non-admins to admin section.
    And it DOES now cause a redirect loop on the actions that were, before, loading the whole home page into the middle of the template.


    Andrew Tibbetts
    Participant

    @andrewgtibbetts

    Thought I had found the silver bullet here:

    https://buddypress.org/support/topic/need-to-disable-the-user-access-to-wordpress-admin-panel/#post-183537

    which includes a check for ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )…still has a redirect loop when performing the ajax actions.

    The search continues…


    Andrew Tibbetts
    Participant

    @andrewgtibbetts

    Ok, the one i found that has the ajax check does work.
    I have narrowed all issues down to a redirect loop on ajax actions inside a custom loop on a page template.
    Starting a new topic… thanks all.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Buttons + Tabs Loading Whole Site Into Template’ is closed to new replies.
Skip to toolbar