WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 2 years ago

#15508 closed enhancement (fixed)

Use !is_user_logged_in instead of !$user->ID

Reported by: Eteq Owned by:
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.0.1
Component: Comments Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

The subject line pretty much says all. I'm kind of integrating a user system of my own to allow comments into wordpress posts as if logged in amongst other few minor changes like session sharing. I've managed to do so as a plugin, until I got stuck with this.

The fact that many places in the wordpress code checks for the user id, instead of using the is_user_looged_in renders the purpose of that function useless for plugins.

Attachments (3)

15508.diff (4.0 KB) - added by garyc40 5 years ago.
there's a patch for that
15508.patch (2.8 KB) - added by ocean90 2 years ago.
15508.2.patch (4.0 KB) - added by ocean90 2 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 @nacin5 years ago

  • Keywords needs-patch added; user login plugin removed
  • Milestone changed from Awaiting Review to Future Release

comment:2 @johnbillion5 years ago

  • Cc johnbillion@… added

I'll volunteer to patch this one up unless Eteq or someone else wants to.

comment:3 @SergeyBiryukov5 years ago

  • Keywords reporter-feedback added

Any examples? I've found only one instance in wp-includes/capabilities.php:

if ( ! $user || ! $user->ID )
	return false;

@garyc405 years ago

there's a patch for that

comment:4 @garyc405 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

comment:5 @iseulde2 years ago

  • Component changed from General to Comments

comment:6 @SergeyBiryukov2 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Future Release to 3.7
  • Severity changed from major to normal

@ocean902 years ago

@ocean902 years ago

comment:7 @ocean902 years ago

  • Keywords 2nd-opinion added; needs-testing removed

15508.patch includes the changes from 15508.diff for wp-includes/comment-template.php.

Not sure if we have to change wp-comments-post.php too, since we already have $user->exists() here. I have included it in 15508.2.patch.

comment:8 @ocean902 years ago

In 25562:

Replace !$user_ID with !is_user_logged_in(). props garyc40. see #15508.

comment:9 @ocean902 years ago

  • Resolution set to fixed
  • Status changed from new to closed

There is no difference between $user->exists() and is_user_logged_in() for wp-comments-post.php. If you overwrite is_user_logged_in() you probably overwrite wp_get_current_user() too, so no need to change something here.

Calling as fixed.

Note: See TracTickets for help on using tickets.