Home › Forums › Add-ons › Options Page › Combine Two PHP Scripts › Reply To: Combine Two PHP Scripts
Does each user have their own options page? Or that is what you’re looking for, so that each person can create their own values for all the options?
In order to have all those custom field names you’d have to create them dynamically in the first place. First you need to export the field group from ACF and then make modification to it.
So, first you’d need to generate all the field groups dynamically based on the logged in user.
<?php
$username = 'user_1'; // whatever code you use to get the user name
if(function_exists('register_field_group')) {
$field_group = array(
'id' => 'acf_adwords',
'title' => 'Adwords',
'fields' => array(
array(
'key' => '_key_adwords_cost_for_'.$username,
'label' => 'Adwords Cost For '.$username,
'name' => 'adwords_cost_for_'.$username,
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'none',
'maxlength' => '',
),
),
'location' => array(
array(
array(
'param' => 'options_page',
'operator' => '==',
'value' => 'acf-options-my-options-page',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array(
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array(),
),
'menu_order' => 0,
);
register_field_group($field_group);
}
?>
Now that you’ve generated a dynamic option name based on the logged in user you can retrieve the value based on the logged in user.
That’s going to make for a lot of options in your option table.
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.