Support » Networking WordPress » What should be the link to dashboard if I use a button in the sidebar of blog?

  • Resolved mahendar

    (@mahendar)


    Hello.I have a multisite. I want to place a button in the sidebar of every blog that links to the dashboard of that blog. I removed the frontend admin bar. So,what is the link I should use in the url field of the button? If blog1.com admin clicks on the button,he should be directed to his own dashboard and if blog2.com admin clicks on the button,he should be directed to his own dashboard. I would be grateful if someone helps.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Plugin Review Team Rep

    You would really be best served by hardcoding it into the themes but … that’s going to be tricky code. Are admins ever admins of multiple sites?

    I have a snippet that goes in that direction here:

    http://wordpress.org/support/topic/adminbar-needs-to-link-to-users-primary-blog?replies=7

    if (is_multisite() && is_user_logged_in()) {
    		$user_id = get_current_user_id();
    		$primary_blog = get_active_blog_for_user( $user_id );
    			if($primary_blog) {
    				$primary_url = 'http://'.$primary_blog->domain . $primary_blog->path;
    				$admin_url = $primary_url.'wp-admin/';
    			} else {
    				$admin_url = get_dashboard_url( $user_id );
    			}

    Thanks Mika and David.
    @david,I am new to wordpress,can you tell me where I have to place the above code.

    echo $admin_url in “the url field of the button”.

    You said “I want to place a button in the sidebar” so I presumed you had a button in your sidebar ready to go.

    You do not have a button?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘What should be the link to dashboard if I use a button in the sidebar of blog?’ is closed to new replies.