Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#25202 closed defect (bug) (invalid)

IS_PROFILE_PAGE not detectable by plugins on Network/user-edit page

Reported by: ipstenu's profile Ipstenu Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:

Description

I was testing MP6, which uses if ( defined( 'IS_PROFILE_PAGE' ) ) to detect if you're on a profile page, and to load a JS there if so.

When I went to /wp-admin/network/user-edit.php their JS wasn't loading.

If I add define('IS_PROFILE_PAGE', true); to that page, everything works, but it appears that the require for /wp-admin/user-edit.php doesn't pull that define in.

No idea at all if this is the right fix to force it in, or if the plugin should be detecting something else, or if this is endemic of an even bigger problem.

Attachments (1)

add-define-25202.diff (436 bytes) - added by Ipstenu 11 years ago.
Adding in the define by force

Download all attachments as: .zip

Change History (14)

@Ipstenu
11 years ago

Adding in the define by force

#1 follow-up: @SergeyBiryukov
11 years ago

IS_PROFILE_PAGE is only defined when you're viewing your own profile, in which case you're on wp-admin/network/profile.php, not on wp-admin/network/user-edit.php. The latter URL is only used for editing another users.

#2 @SergeyBiryukov
11 years ago

  • Keywords needs-patch removed

#3 in reply to: ↑ 1 ; follow-up: @Ipstenu
11 years ago

Replying to SergeyBiryukov:

IS_PROFILE_PAGE is only defined when you're viewing your own profile

No it's not. It's also called when I, the admin, am editing someone else's profile. At least it is on a single site instance, or when I go to edit a user on a specific site of a Multisite network. It's not when I'm using the network edit user link.

#4 in reply to: ↑ 3 @dd32
11 years ago

You're both "right".

IS_PROFILE_PAGE is defined in single-site for both user-edit AND profile.php. It's defined as true when it's your own profile, false when it's not. It's not defined in the Network Admin at all. ever.

It's, IMHO, a vestige of the past and only there for compatibility purposes. MP6 and other plugins shouldn't be using it. Instead, plugins should be checking what the current screen is instead.

IMHO, This is a invalid/wontfix ticket.

#5 @SergeyBiryukov
11 years ago

Replying to dd32:

IS_PROFILE_PAGE is defined in single-site for both user-edit AND profile.php. It's defined as true when it's your own profile, false when it's not.

Yes, by "defined" I meant "true", sorry for being unclear. There's a check in user-edit.php:
http://core.trac.wordpress.org/browser/tags/3.6/wp-admin/user-edit.php#L14

Replying to dd32:

It's not defined in the Network Admin at all. ever.

It is for me, on the same conditions as in single site. Network admin just includes profile.php and user-edit.php from the main wp-admin directory:
http://core.trac.wordpress.org/browser/tags/3.6/wp-admin/network/profile.php
http://core.trac.wordpress.org/browser/tags/3.6/wp-admin/network/user-edit.php

#6 @dd32
11 years ago

It is for me

oops, right, I forgot it's just using the single-site files, and didn't actually test it.

#7 @SergeyBiryukov
11 years ago

So, IS_PROFILE_PAGE is only true when viewing your own profile, and false otherwise, in both single site and Multisite. This appears to be the expected behaviour, I don't see a bug here.

#8 @helen
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

That's my experience - IS_PROFILE_PAGE indicates you are editing your own profile. MP6 is doing this wrong.

#9 follow-up: @Ipstenu
11 years ago

The WP is 'doing it wrong' too, because IS_PROFILE_PAGE also works when an admin is editing another user's profile. So if that's not expected behavior, shouldn't WP be fixed?

#10 in reply to: ↑ 9 @SergeyBiryukov
11 years ago

Replying to Ipstenu:

The WP is 'doing it wrong' too, because IS_PROFILE_PAGE also works when an admin is editing another user's profile.

It does not for me on a clean install. There's a check in user-edit.php that explicitly defines IS_PROFILE_PAGE as true only if it's your own profile: http://core.trac.wordpress.org/browser/tags/3.6/wp-admin/user-edit.php#L14.

Is it defined somewhere earlier on your install?

#11 @Ipstenu
11 years ago

Not that I'm aware of, but it's time to strip mine my install and hunt it down :) Let's assume my install is screwy and MP6 should do it different.

#12 @nacin
11 years ago

IS_PROFILE_PAGE is always defined on user-edit.php or profile.php. On profile.php, it is defined as true. On user-edit.php, if it is not defined, it is defined as false (or true, if you managed to hit your profile directly via user-edit.php).

I am not sure why MP6 wasn't working here. But I wouldn't recommend ever consulting IS_PROFILE_PAGE directly.

Note: See TracTickets for help on using tickets.