Link locations wrong in admin bar drop down & can I create network profile page

Hi All,

I’m not sure if this would be better in general instead of domain mapping but the issue is as follows:

I’m using the domain mapping plugin and I have an issue which actually is on one of the non-mapped sites where under the My Sites menu in the admin bar the links aren’t navigating away from that subsites folder.

eg. The user is on the subsite.

and wants to click on the link to mainsite dashboard but the link takes the user to:

sitename.com/subsite/wp-admin which is where they already are.

I can live with this but I don’t want my users to get confused can I Hide the My Sites menu to only admins/editors and authors user groups?

I also have an issue where I want my site members only to get to their profile page on the parent site.

eg. the user is on a subsite: sitename.com/subsite

And they click on their ‘name’ or ‘My Profile’ in the top right menu I want them to go to their profile page on the mainsite NOT the subsite.

sitename.com/wp-admin/users.php

Any ideas?

  • Michael Bissett
    • Recruit

    Hey @cs_team, hope you’re doing well this evening! :slight_smile:

    First off, could you try updating to the latest version of Domain Mapping please?

    In regards to the first issue, I’d like to see this in action. Could you enable Support Access to your Multisite, and mention which subsite is affected here?

    In regards to this:

    I also have an issue where I want my site members only to get to their profile page on the parent site.

    eg. the user is on a subsite: sitename.com/subsite

    And they click on their ‘name’ or ‘My Profile’ in the top right menu I want them to go to their profile page on the mainsite NOT the subsite.

    sitename.com/wp-admin/users.php

    While something like this would require some custom coding, you may wish to try using BuddyPress for this, as it would provide a profile page on the main site.

    How does this sound? :slight_smile:

    Please advise,

    Michael

  • CS_Team
    • Site Builder, Child of Zeus

    Hi Michael,

    Thanks for your quick reply,

    The subsite is /forum that has the affected ‘My Sites’ menu.

    I have enabled support.

    We have duplicated the theme so that the user is unaware they are between two sites but this helps with conflicts with the forum plugin.

    This is why we want to redirect the profile page. Unfortunately as the customer already had the chosen forum software before I worked for them I unable to change it so can’t install buddypress.

    can you offer any advice on a simple 301 redirect from one url to another and I can add it to .htaccess

    eg

    Redirect 301 /forum/wp-admin/profile.php /wp-admin/profile.php

    Will this work, I haven’t had much practice with .htaccess rules?

  • Ash
    • WordPress Hacker

    Hello @cs_team

    I hope you are well today.

    Both of your issues are default behavior in a multisite unless I am missing something. But yes, you can hide My Sites menu. You need to use the following code:

    add_action( 'admin_bar_menu', 'remove_site_dropdown', 999 );
    function remove_site_dropdown( $wp_admin_bar ) {
    if( current_user_can('editor') || current_user_can('administrator') ){

    }else{
    $wp_admin_bar->remove_node( 'my-sites' );
    }
    }

    To change profile link, use the following code:

    add_action( 'admin_head', 'change_profile_link' );
    function change_profile_link() {
    ?>
    <script type="text/javascript">
    jQuery(function($) {
    $('#wp-admin-bar-edit-profile a').attr( 'href', '<?php echo network_site_url() ?>wp-admin/profile.php' );
    });
    </script>
    <?php
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers

    Ash

  • CS_Team
    • Site Builder, Child of Zeus

    Hi Ash

    Thanks for the reply no something is a little wrong.

    Under the site /forum

    in the My Sites Menu the listing is as follow

    My Sites

    Mainsite – This links to mainsite/forum ‘dashboard’ and ‘visit site’ not mainsite.

    Directory – This links wrong as above but mainsite/forum/directory

    Directory2 – This links wrong as above mainsite/forum/directory2

    Forum – This links to forum dashboard & site fine

    AnotherSite – This link however is fine and so are two other links below the one /forum it seems anything above it on the menu the links are wrong but below is ok?

    I can remove the menu if needed using the branding plugin but it obviously is a good navigation tool and would rather leave it if possible.

    I was going to get round it by making the menu in the branding plugin and adding it but as members of the site can visit the dashboard to add posts for the sites they are members of in the network I didn’t want to add links they can’t use just so the admin users to quickly get to the restricted sites dashboard. Because of course the My sites menu only shows them sites they are members of.

    Thanks for the advice on the profile link I am going to see how this works.

  • CS_Team
    • Site Builder, Child of Zeus

    So to confirm under Network Admin the ‘My Sites’ links are all ok but if you go to the dashboards in the main site or subsites and hover over the links on the ‘My Sites’ dropdown you will see as they appear in the corner of the browser that they are not consistent or pointing to where they should be.

  • CS_Team
    • Site Builder, Child of Zeus

    Hi Ash,

    Enabled.

    Also observed – if under the mapped domain:

    http://www.letdirectory.com/wp-admin/post.php?post=25&action=edit

    and click ‘Preview changes’ then the preview loads as it should

    BUT

    if under mainsite domain

    https://www.landlordreferencing.co.uk/landlord-services/wp-admin/post.php?post=25&action=edit

    and click ‘preview changes’ the link doesn’t work because it removes the /landlord-services/ part from the URL

    I think these issues may be interlinked.

  • Ash
    • WordPress Hacker

    Hello @cs_team

    Yes, I have taken a deep look. It seems really strange as the conflict is with domain mapping plugin. Once I disable domain mapping, it comes back to normal.

    Visit site link works for some subsites but doesn’t work for some, the issue is inconsistence.

    Though I can’t replicate it in my test install.

    I am tagging the developer @sam in this thread for his valuable opinion on this. Please extend the support access.

    Cheers

    Ash

  • Ash
    • WordPress Hacker

    Hello @cs_team

    I have just talked to the developer. Would you please send your admin login and ftp login to him so that he can take a deeper look?

    To send me details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question

    Subject: Attn-Sam

    Details: Send all required details (admin info and/or ftp details) with a link of this thread, so that I can track.

    Also post a note here once you send the info.

    He will take a look :slight_smile:

    Cheers

    Ash

  • CS_Team
    • Site Builder, Child of Zeus

    Thanks for your reply Ash,

    I wanted to be sure it was the Domain Mapping plugin causing the issue by deactivating it and the problem does seem to clear with the My Sites links when the plugin is off.

    I appreciate the assistance but the customer is very protective over their ftp details. Are there particular files you need access to? Would ftp access to the plugin folder be sufficient? Can I provide you with any detailed screenshots?

  • Sam
    • The Incredible Code Injector

    Hi @cs_team

    Most probably access to plugins folder will suffice unless you have some special config in your wp-config.php file.

    So i’d suggest ftp access to plugins folder ( even to domain-mapping folder can be enough) and a screenshot from your wp-config.php file.

    Cheers,

    Sam

  • CS_Team
    • Site Builder, Child of Zeus

    Hi Patrick,

    Yes still active issue.

    I know when you log in to look at the issue for us your comments will be is everything up to date? So I am trying to update first, but I have so many areas to test on the dev site first. Unfortunately I can’t replicate the error on the dev site as I obviously don’t map domains to it, so it needs looking at on the live site once everything is updated. I will let you know when ready and email over the requested details.

    Thanks.

  • CS_Team
    • Site Builder, Child of Zeus

    hi Lindsay, I have tried deactivating nearly every plugin to identify a conflict, have you tried the same? Maybe we are both using a particular theme or feature that could be causing this? I am currently at a loss as to why it’s happening.

  • CS_Team
    • Site Builder, Child of Zeus

    All updated, initial tests very promising until under a mapped domain.

    eg.

    If under the main domain as in screenshots supplied before.

    LandlordReferencing.co.uk/ etc

    All menu links now seem correct, even if under a subsite through the main domain eg.

    LandlordReferencing.co.uk/subsite/ they all work

    But if under the mapped domain in the dashboards

    Rentsafeuk/wp-admin

    then the same problems as before.

    Happy to supply screenshots if it will help.

    Thanks

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.