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.07k stars 264 forks source link

issue with pods_ui manage page pagination on front end #5102

Closed senabean33 closed 6 years ago

senabean33 commented 6 years ago

Issue Overview

I have a set of pods_ui forms that I've created on our website's front end that are restricted to a certain set of users, but the users aren't set up with a certain role so I do the permissions check in the page. Works great on page 1 of the 'manage' page but if I navigate to page 2 it throws a 500 and says it can't find the function I use to check permissions ( this function is loaded on 'init' hook), any suggestions?

Expected Behavior

I would expect when navigating thru the pages, the first page to work like the second.

Current Behavior

The function in the page that calls the list of users allowed to use the page ( 'is_ambassador()' ) is loaded on 'init' & it looks like from the 500 error I get, the pods page code runs before init so the function hasn't loaded yet

500: [Mon Aug 13 17:50:20.730036 2018] [:error] [pid 31980] PHP Fatal error: Call to undefined function is_ambassador() in /nas/content/live/hikeitnew/wp-content/plugins/pods/components/Pages.php(1024) : eval()'d code on line 5, referer: https://trails.hikeitbaby.com/my-tn-links/

Steps to Reproduce (for bugs)

  1. Go to https://trails.hikeitbaby.com/my-tn-links/ (login in upper right/ user: hibtester pass: testingP@55word

  2. Navigate to second page of listed trails

  3. Notice the debug values on the very top of page change

Possible Solution

WordPress Environment

``` WordPress Version: 4.9.8 PHP Version: 5.6.36-1+wpengine16 MySQL Version: 5.6.40 Server Software: Apache Your User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36 Session Save Path: /var/lib/php/sessions Session Save Path Exists: Yes Session Save Path Writeable: Yes Session Max Lifetime: 1440 Opcode Cache: Apc: No Memcached: No OPcache: No Redis: No Object Cache: APC: No APCu: No Memcache: No Memcached: Yes Redis: Yes WPDB Prefix: hib_5_ WP Multisite Mode: Yes WP Memory Limit: 512M Pods Network-Wide Activated: Yes Pods Install Location: /nas/content/live/hikeitnew/wp-content/plugins/pods/ Pods Tableless Mode Activated: No Pods Light Mode Activated: No Currently Active Theme: HikeitBaby Subsite Currently Active Plugins: Admin Columns - Pods add-on: 1.0.2 Admin Columns Pro: 4.0.4 Advanced Ads: 1.8.29 Advanced Ads Pro: 1.3.1.2 Bootstrap 3 Shortcodes: 3.3.12 Custom Content Shortcode: 3.7.0 Exports and Reports: 0.7.4 Filters: 0.3 Font Awesome Shortcodes: 4.2 Gravity Forms: 2.3.2 Gravity Forms MailChimp Add-On: 4.3 Gravity Forms Webhooks Add-On: 1.1 Instagram Feed: 1.9.1 Monarch Plugin: 1.2 Page Builder by SiteOrigin: 2.8.2 Pods - Custom Content Types and Fields: 2.7.9 Pods Gravity Forms Add-On: 1.3 Pods SEO: 2.1 SiteOrigin Widgets Bundle: 1.11.2 Support System: 2.1.9.4 SVG Support: 2.3.11 Tabify Edit Screen: 0.9.7 User Switching: 1.0.9 User Switching in Admin Bar: 1.1 WooCommerce: 2.6.7 WooCommerce Helper: 1.7.2 WooCommerce Memberships: 1.8.9 WP Crontrol: 1.5 WP Multisite SSO: 1.0.3 WP Smush: 2.7.6 WP User Avatar: 2.0.7 Yoast SEO: 5.5.1 ```

Pods Package Export (helpful!)

{"meta":{"version":"2.7.9","build":1534267577},"pages":{"my-tg-adopt":{"id":4832,"name":"my-tg-adopt","code":"","type":"page","slug":"my-tg-adopt","options":{"_edit_lock":"1534267186:38567","_edit_last":"38567","sponsor_url":null,"page_title":"My Trail Guide >Adopt A Trail","precode":"<?php \r\n\r\n\r\n switch_to_blog(7);\r\n    $params = array(\r\n        'where' => 'username.ID = '. get_current_user_id(),\r\n        'limit'   => 1  \/\/ Return all rows\r\n    );\r\n    $ambassadors = pods('ambassador', $params);\r\n\r\necho 'user: '.get_current_user_id().'<br\/>';\r\n\r\necho 'total: '.$ambassadors->total().'<br\/>';\r\n    $ambassador = array();\r\n\r\n    $ambassador['ID'] = $ambassadors->display('ID');\r\n    $ambassador['userid'] = $ambassadors->display('username.ID');\r\n\r\n    switch_to_blog(5);\r\n\r\n$a_id = $ambassador['ID'];\r\n\r\necho ' AID# : '. $a_id;","page_template":"page-my-tg-adopt.php","pod":"0","pod_slug":"","admin_only":"","restrict_role":"","roles_allowed":"","restrict_capability":"","capability_allowed":"","restrict_redirect":"","restrict_redirect_login":"","restrict_redirect_url":""}}}}

Workaround or Alternate Solution Until Bug is Addressed

Related Issues and/or PRs

senabean33 commented 6 years ago

Wrong URL, sorry! In Steps to Reproduce (for bugs) It's https://trails.hikeitbaby.com/my-tg-adopt/
NOT https://trails.hikeitbaby.com/my-tn-links/