acf-extended / ACF-Extended

🚀 All-in-one enhancement suite that improves WordPress & Advanced Custom Fields
https://www.acf-extended.com
239 stars 27 forks source link

Warning: Attempt to read property "ID" on null #103

Closed sdenec closed 2 years ago

sdenec commented 2 years ago

Describe the bug When inspecting users the following Warning is displayed in the permalink: Warning: Attempt to read property "ID" on null in /var/www/[...]/wp-content/plugins/acf-extended/includes/modules/ui-user.php on line 167 Thus the permalink has a malformed link pointing to a non existent address. echoing the global "profileuser" results in "NULL"

The user don't have any posts thus maybe don't fulfill the author requirements?

To Reproduce Edit an existing user

Expected behavior Getting the correct user_id to create a working permalink for the user (author)

Screenshots userlist edit_user

WordPress & ACF WordPress version: 6.0.1 ACF Pro version: 5.12.3 ACF add-ons: ACF: Font Awesome 4.0.3

acf-extended commented 2 years ago

Hello,

Thanks for the feedback!

You’re right, WP Core developers removed a global variable on the user profile page since the WP 6.0 version. This warning will be fixed in the upcoming patch. In the meantime, you can fix it by yourself following these instructions:

In the file /acf-extended-pro/includes/modules/ui-user.php line:163:

Replace

global $profileuser;

With

global $user_id;

And in the same file, line:167:

Replace

<strong>Permalink:</strong> <a href="<?php echo get_author_posts_url($profileuser->ID); ?>"><?php echo get_author_posts_url($profileuser->ID); ?></a>

With:

<strong>Permalink:</strong> <a href="<?php echo get_author_posts_url($user_id); ?>"><?php echo get_author_posts_url($user_id); ?></a>

Sorry for the inconvenience.

Have a nice day!

Regards.

tmirks commented 2 years ago

@acf-extended what is your timeline for the next patch version?

acf-extended commented 2 years ago

Hello!

The warning is fixed in the latest 0.8.8.8 release.

Have a nice day!

Regards.