Home › Forums › Front-end Issues › acf_form deleting bottom rows instead of selected rows
I have an acf_form for a repeater attached to user accounts so that users can edit the repeater. When I remove rows from the repeater with my admin account through the backend, everything works as expected. However, when I log in as a user and use the acf_form on the front-end to remove say 5 random rows from the repeater, it removes the bottom 5 rows from the repeater instead and sometimes it flips the option of a select subfield on the rows I selected for removal.
I’ve tried disabling all other plugins and had the same results so it’s not a plugin conflict. I also commented out any functions in my functions.php file that reference the repeater to avoid any conflict. It’s on a custom theme and there hasn’t been any changes to the theme in a long while to trigger this recent issue. So I don’t think it’s a theme conflict either.
Hi @tribaldave
Could you please try it with WordPress’ stock theme to make sure that the issue is not your theme? Also, could you please share the JSON export file of your field group and the code you used so I can test it out on my installation?
Thanks 🙂
I’m working on replacing the theme so I’ll have to report back on that, but for the meantime, here is a copy of the JSON for the field group
[
{
"key": "group_5666edefa5155",
"title": "Company Admin (User Role)",
"fields": [
{
"sub_fields": [
{
"default_value": "",
"maxlength": "",
"placeholder": "",
"prepend": "",
"append": "",
"key": "field_5666ee3fa5fd3",
"label": "Name",
"name": "name",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"readonly": 0,
"disabled": 0
},
{
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"key": "field_5666ee4ba5fd4",
"label": "Email",
"name": "email",
"type": "email",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
}
},
{
"default_value": 0,
"min": "",
"max": "",
"step": "",
"placeholder": "",
"prepend": "",
"append": "",
"key": "field_56788b08dff96",
"label": "Available Units",
"name": "available_units",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"readonly": 0,
"disabled": 0
},
{
"default_value": "",
"min": 0,
"max": "",
"step": "",
"placeholder": "",
"prepend": "",
"append": "",
"key": "field_56788afadff95",
"label": "Add Units",
"name": "add_units",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"readonly": 0,
"disabled": 0
},
{
"multiple": 0,
"allow_null": 0,
"choices": {
"Active": "Active",
"Inactive": "Inactive"
},
"default_value": {
"Inactive": "Inactive"
},
"ui": 0,
"ajax": 0,
"placeholder": "",
"return_format": "value",
"key": "field_5666ee50a5fd5",
"label": "Status",
"name": "status",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"disabled": 0,
"readonly": 0
}
],
"min": 0,
"max": 0,
"layout": "table",
"button_label": "Add Employee",
"collapsed": "",
"key": "field_5666ee11a5fd2",
"label": "Employees",
"name": "employees",
"type": "repeater",
"instructions": "<strong>PLEASE READ CAREFULLY:<\/strong>\r\n<ol>\r\n<li>You may add units or change statuses.<\/li>\r\n<li>Setting an employee's status to <em>Inactive<\/em> will transfer all of their <em>Available Units<\/em> back to your account.<\/li>\r\n<li>An employee MUST be <em>Active<\/em> to add units to their account.<\/li>\r\n<\/ol>",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
}
}
],
"location": [
[
{
"param": "user_role",
"operator": "==",
"value": "company_admin"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": 1,
"description": "",
"modified": 1452103095,
"local": "json"
}
]
and this is the code I used in my page template
<?php
$current_user = wp_get_current_user();
if(in_array('company_admin', $current_user->roles)):
?>
<section class="pad-50px gray-bg content-wrapper clearfix" id="employees">
<div class="aspira-wrapper">
<h4>Your Employees</h4>
<?php
$args = array('post_id' => 'user_' . get_current_user_id(),
'fields' => array('field_5666ee11a5fd2'),
'return' => site_url('/mycourses'),
'submit_value' => __("Save Changes", 'acf'));
acf_form($args);
?>
</div>
</section>
<?php endif; ?>
Hi @tribaldave
I’ve just tested your code on my installation but failed to reproduce the issue. It’s possible that your theme is the culprit. Could you please test it out?
Thanks 🙂
I was also unable to reproduce the issue with the stock twentyseventeen theme, so I’ll have to chalk it up to a theme conflict.
Thanks for your help.
The topic ‘acf_form deleting bottom rows instead of selected rows’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.