The MU forums have moved to WordPress.org

how to link to wp-admin page ? (6 posts)

  1. timmy77
    Member
    Posted 15 years ago #

    Hello everyone,

    I am trying to put - in the footer of a theme - a link to the user's admin page. And I want that link to be correct for each user.

    This is the code I'm using:

    <a href="<?php echo $tmp_user_url; ?>wp-admin/" title="administration">administration</a>

    It should lead to:

    http://blog1.example.com/wp-admin/

    But it works only when a user clicks on it from the home page of his blog. But if he opens *any* other page like the About page, that same link changes to this:

    http://blog1.example.com/about/wp-admin/

    And it redirects him to the login page!!

    Am I using a wrong code for the link in the footer? If so, then what is the right one?

    I would appreciate your help

  2. tankgunk
    Member
    Posted 15 years ago #

    I'd go with this:

    <a href="<?php bloginfo('url'); ?>/wp-admin/" title=administration">administration</a>
  3. dsader
    Member
    Posted 15 years ago #

    <a href="<?php echo admin_url(); ?>">administration</a>

  4. tankgunk
    Member
    Posted 15 years ago #

    I knew I was forgetting something like that...

  5. dsader
    Member
    Posted 15 years ago #

    Oh, something like this may be useful to direct any logged in user while on any blog to their own admin dashboard of their primary blog:

    <?php $primary_blog = get_active_blog_for_user( $current_user->ID );
    echo '<a href="http://'.$primary_blog->domain . $primary_blog->path.'wp-admin/index.php">administration</a>'); ?>
  6. timmy77
    Member
    Posted 15 years ago #

    tankgunk & dsader,

    It's working fine now :)

    Many thanks to both of you..

About this Topic