Templates capablility_allowed in serialized form
-
Seruvs,
I’m new to Pods, I checked the forum, but didn’t find any hint on what’s going wrong … used versions of WordPress is 5.4.1, Pods is 2.7.20.1, theme is Blocksy (I tried TwentyTwenty too, same result).
I setup a Pods template with requested “Capability Allowed” = cap_a, cap_b, and cap_c (added with the Pods Admin / Roles & Capabilites).
Function pods_permission (in general.php) always returns FALSE, regardless of the capabilities the curent user has.My examination of pods_permission (in general.php):
– pods_v( ‘capability_allowed’, $options ) returns a string in format ‘a:3:{i:0;s:5:”cap_a”;i:1;s:5:”cap_b”;i:2;s:5:”cap_c”;}’. This seems to be the serialized list (array) of the requested capability strings with explicitly specified 0-based index and length of string.
– the subsequent block if ( ! is_array( $capabilities ) ) { … doesn’t handle this capability string correctly, it’s not deserializing it.
=> it will return FALSE alwaysI think $must_have_capabilities should be deserialized first using some kind of
(get all substrings “…” from the serialized string):
$must_have_capabilities = (preg_match_all(‘/”([\w|_]+)”/’, $x, $m) === FALSE)
? []
: $m[1];
For sure there is a helper function for this inside Pods (?).Where’s my error in (and lack of) unterstanding the handling of capability restriction for Pods Templates?
It’s not a problem of the Pods Template itself, e.g. if I set permission to TRUE via function assigned to filter ‘pods_templates_permission’, it shows the correct output.
Greetings from Bavaria,
Daniel
- The topic ‘Templates capablility_allowed in serialized form’ is closed to new replies.