pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.06k stars 264 forks source link

Limit list to the same Post Author - Does not work with Comments. #7191

Open Jzsiba opened 9 months ago

Jzsiba commented 9 months ago

Description

Toggling on "Limit list to the same Post Author" works for every other post type I've tried, including the default "posts" post type. But it does not work for Comments. The dropdown is not filtered by posts by the logged in user.

Version

3.0.4

Testing Instructions

  1. In Dashboard -> Click Edit Pods _> Add New
  2. Click Extend Exiting
  3. In Content Type dropdown, select Post Types.
  4. In Post Type, Select Comments
  5. Create new field by clicking Add Field button.
  6. Give it a name, under Field Type select Relationship
  7. Under Related Type, select a previously created custom post type.
  8. Click Relationship Options in right panel.
  9. Under Selection Type, select Single Select.
  10. Scroll down to Display Field in Selection List and put in _{@posttitle}
  11. Scroll to the bottom of the options and select the checkbox for Limit list to same Post Author.

Go to an existing post that has comments enabled and find the Comments form at the bottom of the post. See your dropdown, and get somewhat disappointed by the fact that it will list every post created in the custom post type you selected in step 7 instead of the posts created by the user who is currently logged in and attempted to post a comment.

Screenshots / Screencast

Relationship checkbox.

relationship

My dropdown illustrating posts that are mine, vs the ones that aren't.

dropdown_example

Possible Workaround

WHERE Clause matching author of custom post type to current user logged in ID. post_author.ID = {@user.ID}

Site Health Information

`
### wp-core ###

version: 6.3.1
site_language: en_US
user_language: en_US
timezone: +00:00
permalink: /%year%/%monthnum%/%day%/%postname%/
https_status: true
multisite: true
user_registration: false
blog_public: 1
default_comment_status: open
environment_type: production
site_count: 2
network_count: 1
user_count: 3
dotorg_communication: true

### wp-active-theme ###

name: Twenty Twenty-Three (twentytwentythree)
version: 1.2
author: the WordPress team
author_website: https://wordpress.org
parent_theme: none
theme_features: core-block-patterns, post-thumbnails, responsive-embeds, editor-styles, html5, automatic-feed-links, block-templates, widgets-block-editor
theme_path: /home/hitpoints/public_html/wprpg/wp-content/themes/twentytwentythree
auto_update: Disabled

### wp-themes-inactive (4) ###

Construction: version: 3.7, author: WPCharming, Auto-updates disabled
Intense: version: 1.0.1, author: Flythemes, Auto-updates disabled
Twenty Twenty-One: version: 1.9, author: the WordPress team, Auto-updates disabled
Twenty Twenty-Two: version: 1.5, author: the WordPress team, Auto-updates disabled

### wp-plugins-active (23) ###

Advanced Editor Tools: version: 5.9.2, author: Automattic, Auto-updates disabled
CBX Bookmark & Favorite: version: 1.7.13, author: Codeboxr Team, Auto-updates disabled
Comment Form Editor with TinyMCE: version: 1.0.2, author: Shail Mehta, Auto-updates disabled
GP Advanced Select: version: 1.0.1, author: Gravity Wiz, Auto-updates disabled
GP Email Users: version: 2.0.5, author: Gravity Wiz, Auto-updates disabled
GP Entry Blocks: version: 1.0-alpha-2.28, author: Gravity Wiz, Auto-updates disabled
GP Nested Forms: version: 1.1.37, author: Gravity Wiz, Auto-updates disabled
GP Placeholder: version: 1.3.7, author: David Smith, Auto-updates disabled
GP Populate Anything: version: 2.0.16, author: Gravity Wiz, Auto-updates disabled
Gravity Forms: version: 2.7.14, author: Gravity Forms, Please register your copy of Gravity Forms to enable automatic updates.
Gravity Perks: version: 2.3.4, author: Gravity Wiz, Auto-updates disabled
GUI for List Category Posts: version: 2.0.2, author: Klemens Starybrat, Auto-updates disabled
JSM Force HTTP to HTTPS / SSL: version: 3.4.1, author: JS Morisset, Auto-updates disabled
JSM Show Comment Metadata: version: 3.2.0, author: JS Morisset, Auto-updates disabled
JSM Show Post Metadata: version: 3.2.0, author: JS Morisset, Auto-updates disabled
LCP Ajax Pagination: version: 0.1.5, author: Klemens Starybrat, Auto-updates disabled
List category posts: version: 0.89, author: Fernando Briano, Auto-updates disabled
MultiSite Clone Duplicator: version: 1.5.3, author: Julien OGER, Pierre DARGHAM, David DAUGREILH, GLOBALIS media systems, Auto-updates disabled
Pods - Custom Content Types and Fields: version: 3.0.4, author: Pods Framework Team, Auto-updates disabled
Pods Gravity Forms Add-On: version: 1.4.5, author: Pods Framework Team, Auto-updates disabled
Ultimate Addons for WPBakery Page Builder: version: 3.19.18, author: Brainstorm Force, Auto-updates disabled
WPBakery Page Builder: version: 7.0, author: Michael M - WPBakery.com, Auto-updates disabled
WP Test Email: version: 1.1.6, author: Boopathi Rajan, Auto-updates disabled

### wp-plugins-inactive (3) ###

Akismet Anti-spam: Spam Protection: version: 5.3, author: Automattic - Anti-spam Team, Auto-updates disabled
Character dropdoen: version: 1.0, author: Jason, Auto-updates disabled
Multisite Post Duplicator: version: 1.7.6, author: Mario Jaconelli, Auto-updates disabled

### wp-media ###

image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1692
imagemagick_version: ImageMagick 6.9.12-93 Q16 x86_64 17898 https://legacy.imagemagick.org
imagick_version: 3.7.0
file_uploads: File uploads is turned off
post_max_size: 200
upload_max_filesize: 80
max_effective_size: 80 B
max_file_uploads: 20
imagick_limits: 
    imagick::RESOURCETYPE_AREA: 30 GB
    imagick::RESOURCETYPE_DISK: 9.2233720368548E+18
    imagick::RESOURCETYPE_FILE: 768
    imagick::RESOURCETYPE_MAP: 15 GB
    imagick::RESOURCETYPE_MEMORY: 7 GB
    imagick::RESOURCETYPE_THREAD: 1
    imagick::RESOURCETYPE_TIME: 9.2233720368548E+18
imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FLV, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV
gd_version: 2.3.2
gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM
ghostscript_version: not available

### wp-server ###

server_architecture: Linux 5.14.0-364.el9.x86_64 x86_64
httpd_software: Apache
php_version: 8.0.27 64bit
php_sapi: fpm-fcgi
max_input_variables: 1000
time_limit: 301
memory_limit: 512M
max_input_time: 60
upload_max_filesize: 80
php_post_max_size: 200
curl_version: 7.76.1 OpenSSL/3.0.7
suhosin: false
imagick_availability: true
pretty_permalinks: true
htaccess_extra_rules: false
current: 2023-09-29T06:44:52+00:00
utc-time: Friday, 29-Sep-23 06:44:52 UTC
server-time: 2023-09-29T06:44:52+00:00

### wp-database ###

extension: mysqli
server_version: 10.5.16-MariaDB
client_version: mysqlnd 8.0.27
max_allowed_packet: 67108864
max_connections: 151

### wp-constants ###

WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /home/hitpoints/public_html/wprpg/wp-content
WP_PLUGIN_DIR: /home/hitpoints/public_html/wprpg/wp-content/plugins
WP_MEMORY_LIMIT: 64M
WP_MAX_MEMORY_LIMIT: 512M
WP_DEBUG: false
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: Undefined
WP_DEVELOPMENT_MODE: undefined
DB_CHARSET: utf8mb4
DB_COLLATE: undefined

### wp-filesystem ###

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable

### pods ###

pods-server-software: Apache
pods-user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0
pods-session-save-path: /home/hitpoints/tmp
pods-session-save-path-exists: Yes
pods-session-save-path-writable: Yes
pods-session-max-lifetime: 1440
pods-opcode-cache-apc: No
pods-opcode-cache-memcached: No
pods-opcode-cache-opcache: Yes
pods-opcode-cache-redis: No
pods-object-cache-apc: No
pods-object-cache-apcu: No
pods-object-cache-memcache: No
pods-object-cache-memcached: No
pods-object-cache-redis: No
pods-memory-current-usage: 12.240M / 64M
pods-memory-current-usage-real: 14.000M
pods-network-wide: Yes
pods-install-location: /wp-content/plugins/pods/
pods-developer: No
pods-tableless-mode: No
pods-relationship-table-enabled: Yes
pods-relationship-table-status: 8
pods-light-mode: No
pods-strict: No
pods-allow-deprecated: Yes
pods-api-cache: Yes
pods-shortcode-allow-evaluate-tags: No
pods-sessions: Disable sessions
pods-can-use-sessions: Yes
pods-settings-types_only: No
pods-settings-watch_changed_fields: No
pods-settings-metadata_integration: Yes
pods-settings-metadata_override_get: No

`

Pods Package

I am currently unable to export anything, the interface produces the following error

Error: Invalid AJAX request
Jzsiba commented 9 months ago

I've fixed the invalid ajax error issue. Here is my pods package export { "@meta": { "version": "3.0.4", "build": 1695971772 }, "settings": { "types_only": "0", "watch_changed_fields": "0", "metadata_integration": "1", "metadata_override_get": "0", "media_modal_fields": "0", "session_auto_start": "0", "wisdom_opt_out": "1", "active_components": [ "migrate-packages", "roles-and-capabilities", "templates" ] }, "pods": [ { "name": "chapter", "id": 16, "label": "Chapters", "description": "", "type": "post_type", "storage": "meta", "label_singular": "Chapter", "public": "1", "show_ui": "1", "rest_enable": "1", "supports_title": "1", "supports_editor": "1", "_migrated_28": "1", "show_in_menu": "1", "menu_position": "0", "show_in_nav_menus": "1", "show_in_admin_bar": "1", "default_status": "publish", "pick_object": "custom-simple", "required": "0", "supports_comments": "1", "groups": [ { "name": "more_fields", "id": 17, "label": "More Fields", "description": "", "weight": 0, "fields": [ { "name": "post_as", "id": 18, "label": "Post As", "description": "Select your character", "weight": 0, "type": "pick", "pick_object": "post_type", "pick_val": "character", "sister_id": "-- Select One --", "pick_table": "-- Select One --", "required": "1", "pick_format_type": "single", "pick_format_single": "dropdown", "pick_format_multi": "list", "pick_display_format_multi": "default", "pick_display_format_separator": ", ", "pick_allow_add_new": "0", "pick_taggable": "0", "pick_show_icon": "1", "pick_show_edit_link": "1", "pick_show_view_link": "1", "pick_limit": "0", "pick_user_role": "Administrator", "pick_post_status": "publish", "pick_post_author": "1", "repeatable": "0", "repeatable_format": "default", "roles_allowed": "administrator", "enable_conditional_logic": "0", "rest_pick_response": "array", "rest_pick_depth": "1", "pick_display": "{@post_title}" } ] } ] }, { "name": "character", "id": 5, "label": "Characters", "description": "", "type": "post_type", "storage": "meta", "label_singular": "Character", "public": "1", "show_ui": "1", "rest_enable": "1", "supports_title": "1", "supports_editor": "1", "_migrated_28": "1", "default_status": "publish", "can_export": "1", "show_in_nav_menus": "1", "show_in_admin_bar": "0", "delete_with_user": "1", "pick_object": "custom-simple", "required": "0", "groups": [ { "name": "more_fields", "id": 6, "label": "More Fields", "description": "", "weight": 0, "fields": [ { "name": "avatar", "id": 10, "label": "Avatar", "description": "Avatar", "weight": 0, "type": "file", "sister_id": "-- Select One --", "required": "0", "file_format_type": "single", "file_uploader": "attachment", "file_type": "images", "file_attachment_tab": "upload", "file_upload_dir": "wp", "file_edit_title": "1", "file_show_edit_link": "1", "file_linked": "1", "file_limit": "0", "file_field_template": "rows", "file_add_button": "Add Avatar", "file_modal_title": "Attach an Avatar", "file_modal_add_button": "Add Avatar", "file_wp_gallery_link": "file", "file_wp_gallery_columns": "3", "file_wp_gallery_size": "thumbnail", "repeatable": "0", "repeatable_format": "default", "roles_allowed": "administrator", "enable_conditional_logic": "0", "rest_pick_response": "array", "rest_pick_depth": "1", "class": "char_avatar" }, { "name": "age", "id": 7, "label": "Age", "description": "How old is this character?", "weight": 1, "type": "number", "sister_id": "-- Select One --", "required": "0", "number_format_type": "number", "number_format": "i18n", "number_decimals": "0", "number_format_soft": "0", "number_step": "1", "number_max_length": "12", "number_html5": "1", "repeatable": "0", "repeatable_format": "default", "roles_allowed": "administrator", "enable_conditional_logic": "0", "rest_pick_response": "array", "rest_pick_depth": "1" } ] } ] }, { "name": "comment", "id": 24, "label": "Comment", "description": "", "type": "comment", "storage": "meta", "object": "comment", "_migrated_28": "1", "pick_object": "custom-simple", "required": "0", "pfat_enable": "1", "pfat_archive": "Generic Comments Template", "pfat_filter_archive": "comment_text", "pfat_append_archive": "replace", "groups": [ { "name": "more_fields", "id": 25, "label": "More Fields", "description": "", "weight": 0, "fields": [ { "name": "post_as", "id": 26, "label": "Post As", "description": "Select your character", "weight": 0, "type": "pick", "pick_object": "post_type", "pick_val": "character", "sister_id": "-- Select One --", "pick_table": "-- Select One --", "required": "1", "pick_format_type": "single", "pick_format_single": "dropdown", "pick_format_multi": "list", "pick_display_format_multi": "default", "pick_display_format_separator": ", ", "pick_allow_add_new": "0", "pick_taggable": "0", "pick_show_icon": "1", "pick_show_edit_link": "0", "pick_show_view_link": "0", "pick_limit": "0", "pick_user_role": "Administrator", "pick_post_status": "publish", "pick_post_author": "1", "repeatable": "0", "repeatable_format": "default", "roles_allowed": "administrator", "enable_conditional_logic": "0", "pick_display": "{@post_title}", "conditional_logic": { "action": "show", "logic": "any", "rules": [ { "field": "post_as", "compare": "=", "value": "" } ] }, "class": "post_as_dropdown", "logged_in_only": "1" } ] } ] }, { "name": "post", "id": 31, "label": "Posts", "description": "", "type": "post_type", "storage": "meta", "object": "post", "_migrated_28": "1", "pick_object": "custom-simple", "required": "0", "pfat_enable": "1", "pfat_filter_single": "the_content", "pfat_filter_archive": "the_excerpt", "pfat_run_outside_loop": "0", "pfat_single": "Generic Post Template", "pfat_append_single": "replace", "groups": [ { "name": "more_fields", "id": 32, "label": "More Fields", "description": "", "weight": 0, "fields": [ { "name": "selected_char", "id": 33, "label": "Post As", "description": "Select your character", "weight": 0, "type": "pick", "pick_object": "post_type", "pick_val": "character", "sister_id": "-- Select One --", "pick_table": "-- Select One --", "required": "1", "pick_format_type": "single", "pick_format_single": "dropdown", "pick_format_multi": "list", "pick_display_format_multi": "default", "pick_display_format_separator": ", ", "pick_allow_add_new": "0", "pick_taggable": "0", "pick_show_icon": "1", "pick_show_edit_link": "1", "pick_show_view_link": "1", "pick_limit": "0", "pick_user_role": "Administrator", "pick_post_status": "publish", "pick_post_author": "1", "repeatable": "0", "repeatable_format": "default", "roles_allowed": "administrator", "enable_conditional_logic": "0", "rest_pick_response": "array", "rest_pick_depth": "1", "pick_display": "{@post_title}" } ] } ] } ], "templates": [ { "name": "Generic Comments Template", "code": "<h1>Comment By:{@post_as.post_title}<\/h1>\r\n<hr \/>\r\nBody: {@comment_content}", "id": 42, "_edit_lock": "1695967755:1", "_edit_last": "1", "_wpb_vc_js_status": "false", "pod_reference": { "pod": "comment" }, "admin_only": "0", "restrict_capability": "0", "show_restrict_message": "0", "_pods_capability_allowed": [ "" ] }, { "name": "Generic Post Template", "code": "<h1>Title:{@post_title}<\/h1>\r\n<p><strong>Posted By:{@selected_char.post_title}<\/strong><\/p>\r\n<hr \/>\r\nBody: {@post_content}", "id": 37, "_edit_lock": "1695970188:1", "_edit_last": "1", "_wpb_vc_js_status": "false", "admin_only": "0", "restrict_capability": "0", "show_restrict_message": "0", "_pods_capability_allowed": [ "" ], "pod_reference": { "pod": "post" } } ] }

sc0ttkclark commented 8 months ago

Details about how this field option works --

Option label:

Limit list to the same Post Author

Option help text:

You can choose to limit Posts available for selection to those created by the same Post Author. This only works if this pod is a Post Type and this field is related to a Post Type.

So it's not really designed for post types, however, it's possible we could add support for comment authors here in the future.

Jzsiba commented 8 months ago

That would be most excellent, my workaround does exactly the same thing it's just a seemingly unnecessary extra step.

I do understand why it's acting the way it is, because the comment field doesn't live within a standard posting interface where Pods knows that the person looking at the "new post" interface, is the author of the post, and thus, can tell the dropdown what it should be doing. So my workaround simply uses the logged in users ID.

EDIT: Just to clarify, the dropdown field I added, via pods, to the Comments post type, is supposed to be agnostic to the post being commented on.