WordPress.org

Ready to get started?Download WordPress

Forums

How to add Admin Bar to non-wordpress sites (2 posts)

  1. antmore
    Member
    Posted 2 years ago #

    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: http://www.mysite.com/blog/wp-login.php' ) ;

    };

  2. antmore
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags