Skip to content

Fix Repeater pagination on Options Pages - #613

Merged
cbravobernal merged 1 commit into
trunkfrom
claude/issue-612-47ce87
Dec 3, 2026
Merged

cbravobernal merged 1 commit into
trunkfrom
claude/issue-612-47ce87

Conversation

@cbravobernal

@cbravobernal cbravobernal commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

On an Options Page, clicking Next on a paginated Repeater showed "Sorry, you do not have permission to do that."

The page loader (ajax_get_rows()) ran a second, post-only check after the context check. It cast non-post IDs such as 'options' to 0, so it always failed. This PR removes it. Posts keep the same edit_post check through acf_current_user_can_edit_in_context(), and user profiles, terms, comments and Woo orders now work too, each with its own capability.

The loader takes the field name from the request, because a nested Repeater is stored under a longer name than its own. It now checks that the reference key stored under that name is the requested field's key. Values without a reference key, such as imported data, still load.

It also gives field_prefix a default, so a page load no longer logs an "undefined array key" warning.

Testing instructions

  1. Register an Options Page with acf_add_options_page(), using the edit_posts capability.
  2. Add a Repeater with pagination enabled and save enough rows for a second page.
  3. Log in as an Editor, open the Options Page and click Next. The second page loads.

vendor/bin/phpunit --filter Test_ACF_Field_Repeater_Ajax_Permissions covers Options Pages, posts, a field name saved by another field, and Repeaters inside a Group or a Clone field.

Closes #612

Use of AI Tools

This PR was written with Claude Code (Claude Opus 5.5): the fix, the tests and this description.

🤖 Generated with Claude Code

Loading the next page of a paginated Repeater on an Options Page failed
with "Sorry, you do not have permission to do that." The page loader ran
a second, post-only check after the context check. It cast non-post IDs
such as 'options' to 0, so it always failed. The context check already
covers posts, so the second check is removed.

The loader takes the field name from the request, because a nested
Repeater is stored under a longer name than its own. Before loading rows,
it now checks that the reference key stored under that name is this
field's key. Values without a reference key, such as imported data,
still load.

Also give field_prefix a default, so loading a page no longer logs an
undefined array key warning.

Fixes #612.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cbravobernal
cbravobernal force-pushed the claude/issue-612-47ce87 branch from c71ebcf to deda201 Compare December 1, 2026 14:50
@cbravobernal
cbravobernal merged commit e47acdd into trunk Dec 3, 2026
31 of 33 checks passed
@cbravobernal
cbravobernal deleted the claude/issue-612-47ce87 branch December 3, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repeater pagination on an Options Page fails with a permission error in SCF 6.9.10

1 participant