Pods: Users with user_status not set to 0 are being excluded from relationships and lists using Pods code

Created on 11 Apr 2020  Â·  7Comments  Â·  Source: pods-framework/pods

Issue Overview


There appear to be a few bugs with bidirectional relationship, multiselect fields.

Expected Behavior

I expect the bidirectional multiselect field and autocomplete field to work correctly.

Current Behavior

I have a bidirectional relationship field Members (User single) and Organization (Organization multi).

From the organization page I can add users and it works and saves to the database. However the newly added users don’t show up in the autocomplete input field on reload, even though the database entries are made correctly and on the User page itself, it shows the organization.

If I use a multiselect field instead of an autocomplete, I can see the Users that belong to that Organization.

Also I noticed in the Advanced section in Organizations Pods settings under visibility it lists “Restrict access by role”. If I check a role and leave Administrator unchecked, I can still see that field information in the edit Organization page.

In addition, under “Additional Field Options” > “Limit list to role”, if I check two valid User roles I created “Assessor” and “Organization Admin”, if I visit the edit Organization page, I can add Assessors and Organization Admins, but when I reload the page, they don’t show up in the list. If I go back and deselect “Limit list to role”, the previously added Users magically appear.

The “Limit list to role” bug doesn’t exist with the checkbox AND multi select field but does exist with the List View AND Autocomplete fields. Strangely, with the Autocomplete field, it shows 2 of the 3 Users belonging to the Organization, whereas the List View shows none (and the checkbox and multi select show all 3 selected = correct).

Steps to Reproduce (for bugs)

  1. Create a bidirectional relationship between two custom post types, in my case Organization > "users" field (multiple) AND User > "organization" field (single)
  2. Set the organization's users field to be a multiple selection autocomplete field
  3. Create an organization in the backend, add multiple users to the organization
  4. Reload the page - at this point, the "users" previously added to that field disappear

The other variations of this bug are described above.

Possible Solution

It seems like whatever filter is determining the currently selected fields is off. Don't know enough about how this is done.

WordPress Environment


Debug Information
WordPress Version: 5.4

PHP Version: 7.3.16

MySQL Version: 5.6.40

Server Software: Apache

Your User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36

Session Save Path: /tmp

Session Save Path Exists: Yes

Session Save Path Writeable: Yes

Session Max Lifetime: 1440

Opcode Cache:

Apc: No
Memcached: No
OPcache: Yes
Redis: No
Object Cache:

APC: No
APCu: No
Memcache: No
Memcached: Yes
Redis: No
WPDB Prefix: yap_

WP Multisite Mode: No

WP Memory Limit: 256M

Current Memory Usage: 22.974M

Current Memory Usage (real): 26.000M

Pods Network-Wide Activated: No

Pods Install Location: /home/yaptool9/public_html/wp-content/plugins/pods/

Pods Tableless Mode Activated: No

Pods Light Mode Activated: No

Currently Active Theme: YAP Theme

Currently Active Plugins:

All-in-One WP Migration: 7.19
Astra Pro: 2.3.4
Elementor: 2.9.7
Elementor Pro: 2.9.2
FacetWP: 3.5.2.1
FacetWP - Pods integration: 1.2.2
Gravity Forms: 2.4.17
Gravity Forms Partial Entries Add-On: 1.4
Gravity Forms Signature Add-On: 3.8
Gravity Forms User Registration Add-On: 4.4
Gravity PDF: 5.2.2
GravityView: 2.7.1
GravityView - Advanced Filter Extension: 2.0.3
GravityView - DataTables Extension: 2.4.2
Members: 2.2.0
Nav Menu Roles: 1.10.1
Pods - Custom Content Types and Fields: 2.7.20
Save and Continue Link Recovery for Gravity Forms: 2.0
Shield Security: 8.7.0
ShortPixel Image Optimizer: 4.17.1
WP-Members: 3.3.2.2
WP Rocket: 3.5.2
YAP: 1.0.1

Pods Package Export (helpful!)




I don't see an export option after enabling the option under migrate..

Workaround or Alternate Solution Until Bug is Addressed

The bugs don't exist with the checkbox field.

Related Issues and/or PRs

https://github.com/pods-framework/pods/issues/5542

Multisite Bug

All 7 comments

Working with you directly but I've been unable to reproduce this issue yet. Will see what your staging site can help uncover here.

After some back and forth, we were able to determine the cause of this was not the relationship field but the way we query users by default. In Pods, we query users and limit that query by user_status = 0. Historically, the user_status database field was used by WP Multisite to determine whether a user was marked as "spam". 1 would be spam, and 0 would be normal. Over time, that column usage has been removed or downplayed by WordPress itself. It's now mostly a relic of the past and some plugins may end up using that column for their own purposes because of the column's disuse.

As a result of the query we make, it would not return some users in @ridinghoodmedia's client site for relationships or any Pods find() query for users which is used all over by Pods for shortcodes and other things. Some of the users on the site (7 to be exact) had user_status set to 2 which excluded them from those lists.

As we are moving on from older WordPress versions as part of Pods 2.8's new codebase, there's room to address this without backwards compatible concerns of the older installs. We will address this particular issue in Pods 2.8 in the release/2.8 branch, and that fix will go out with that release in the coming weeks when it goes into Beta and the final release following that.

@sc0ttkclark Thanks for looking into it

One thing about the issue we're referencing (the user status one), I'm not sure it's directly related to the other bugs in this original ticket. The other issues being:

  1. The bug related to ajax (or so we think)
    From the organization page I can add users and it works and saves to the database. However the newly added users don’t show up in the autocomplete input field on reload, even though the database entries are made correctly and on the User page itself, it shows the organization.

  2. The limit list to role bug
    In addition, under “Additional Field Options” > “Limit list to role”, if I check two valid User roles I created “Assessor” and “Organization Admin”, if I visit the edit Organization page, I can add Assessors and Organization Admins, but when I reload the page, they don’t show up in the list. If I go back and deselect “Limit list to role”, the previously added Users magically appear.

The “Limit list to role” bug doesn’t exist with the checkbox AND multi select field but does exist with the List View AND Autocomplete fields. Strangely, with the Autocomplete field, it shows 2 of the 3 Users belonging to the Organization, whereas the List View shows none (and the checkbox and multi select show all 3 selected = correct).

Bug 2 I haven't looked at since I opened the ticket (not sure if it has been addressed in a previous release but I can make a video on it)

@ridinghoodmedia That definitely sounds like a different issue, I'll come back to that and get it looked at separately.

@JoryHogeveen can you make a new issue from what OP described? I'm going to close this for now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jcampbell05 picture jcampbell05  Â·  5Comments

Ramoonus picture Ramoonus  Â·  5Comments

devont3 picture devont3  Â·  3Comments

jnaklaas picture jnaklaas  Â·  3Comments

tuanmh picture tuanmh  Â·  5Comments