Small question about link in header

So we have the guest user plug-in installed, but the link in the header to “My Account” (see screenshot) accesses an intermediary “me” page. I want to point that link straight to the “update my account” page. How can I change that link in the header??? I can’t seem to find the appropriate file to change…

Capture

Anyone? Where is that “My Account” created?

That’s in ilterPublicNavigationAdminBar in GuestUserPlugin.php, line 208. Just change the ‘uri’ value.

Keep in mind that any plugins tie in to Guest User features, that might end up hiding those other plugins’ content. But if that’s not an issue, the change should be fine.

2 Likes

Thank you! That helps. I guess I can’t also change the “Welcome, user” link since it’s connected to the admin-users, but that’s not such a big deal.

If I wanted to change the “Welcome, user” link in the above, where would that be? I don’t really understand the point of it directing to the internal admin/users/edit/ since if one is logged in as admin you’ll see “Omeka Admin” anyways. I’d like to either get rid of the link totally or re-direct it to /omeka/guest-user/user/update-account.

Thanks!

@patrickmj or @jflatnes sorry to bug you about this, but any ideas??

Sorry for the delay. It’s actually a little complicated.

The origin of it all is in the application/views/scripts/common/admin-bar.php file. That sets up the minimal, default admin bar.

But, it sounds like you are also using the GuestUser plugin, which does some modifications to it. The admin bar goes through the public_navigation_admin_bar filter, which GuestUser implements to modify what’s there. Those changes are in the GuestUserPlugin.php file’s filterPublicNavigationAdminBar function.

So, there’s a couple options for you. The safest approach is to avoid modifying core files, so you could tinker with how GuestUser modifies things, probably adding your URL changes to get at what you need. Or, you could create your own plugin that also uses that filter, so that changes pass through GuestUser’s filter, then through your own plugin’s filter. That might get complicated, but would give you the most stable control of the outcome.

Changes to GuestUser’s filter might be quicker, but always runs the risk of your changes being clobbered by an update to the plugin (though I doubt that any significant update is in the offing).

Thanks for the reply @patrickmj . It sounds like modifying GuestUser is the fastest and best way at the moment. I’m looking at that function right now and presume I should do something with this line:

            $navLinks[0]['id'] = 'admin-bar-welcome';

I’m not sure what though. Comment it out? I don’t know how/if that would affect anything else negatively.

It’ll be a tad more complicated than that, but not too bad. That $navLinks array contains the data for how Omeka builds up the navigation tabs. It’ll look something like this

Array
(
    [0] => Array
        (
            [label] => Welcome, Super User
            [uri] => /Omeka/admin/users/edit/1
            [id] => admin-bar-welcome
            [pages] => Array
                (
                    [guest-user-me] => Array
                        (
                            [id] => guest-user-me
                            [uri] => /Omeka/guest-user/user/me
                            [label] => My Account
                        )

                )

        )

    [1] => Array
        (
            [label] => Omeka Admin
            [uri] => /Omeka/admin/
        )

    [2] => Array
        (
            [label] => Log Out
            [uri] => /Omeka/users/logout
        )

)

So, commenting that out would only remove the id from the element, probably breaking the CSS.

What you’ll want to do is remove the entire subarray for the element, or alter its uri data, or both. You might have to do some digging around in the actual array that your site produces, since plugins can alter the content of the array through filters. I produced the above code by doing debug(print_r($navLinks, true)); before $navLinks is returned, and looking at the result in the error logs.

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.