• I am having trouble finding a solution, but basically if the user is logged in, i want the admin bar to display on a non-wordpress page.

    I have mastered the “Login/Logout” on non-WP pages, but when someone is logged in, I want them to have the WP admin bar shown instead of “Welcome registered user!”

    could someone tell me which function and php file the admin bar is displaying?

    So in other words, I want my code on non-WP pages to look like this:

    require(‘blog/wp-load.php’);
    require(‘blog/wp-blog-header.php’);

    if ( is_user_logged_in() ) {
    show_admin_bar();
    } else {
    header( ‘Location: https://www.mysite.com/blog/wp-login.php’ ) ;

    };

Viewing 1 replies (of 1 total)
  • Thread Starter antmore

    (@antmore)

    Every time I try to add a function in :

    if ( is_user_logged_in() ) {
    //adding function here
    }

    i get this error:

    Fatal error: Cannot redeclare _wp_admin_bar_init() (previously declared in…/file/to/path/

    Even though I am requiring all these pages that SHOULD let me use the function to call on non-WP pages

    require(‘blog/wp-load.php’);
    require(‘blog/wp-blog-header.php’);
    require(‘blog/wp-includes/admin-bar.php’);
    require(‘blog/wp-config.php’);

    It should treat the non-wordpress page as a WP page and be able to post the admin bar. unless I am posting the wrong function.

Viewing 1 replies (of 1 total)
  • The topic ‘How to add Admin Bar to non-wordpress sites’ is closed to new replies.