Home › Forums › Add-ons › Options Page › Display user option fields on left side bar › Reply To: Display user option fields on left side bar
In functions.php you can do something like this, but I do not know if it will work, I’ve never tried it before.
add_action('init', 'user_specific_options_page');
function user_specific_options_page() {
// check for ACF
if (!function_exists('acf_add_options_page')) {
return;
}
// get current user role
// because I don't know a permission
//shared by all logged in users
$role = 'subscriber';
if (is_user_logged_in()) {
$user wp_get_current_user();
$roles = (array) $user->roles;
$role = $role[0];
}
$args = array(
'page_title' => 'My Options',
'menu_title' => 'My Options',
// allow the user to edit
// I'm really not sure about this one
// you may need to fiddle with this and
// maybe the code getting the current user role
'capability' => $role,
// set it to save values for this user
'post_id' => 'user_'.get_current_user_id(),
);
acf_add_options_page($args);
}
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.