Support

Account

Home Forums Add-ons Options Page Display user option fields on left side bar

Solved

Display user option fields on left side bar

  • I have some group fields for users can change they own options. It’s posible to show there fields on left side bar intead member profile page, such as acf_add_option_page() but values will save to wp_users table?

  • 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);
    }
    
  • Thanks, it work perfect!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Display user option fields on left side bar’ is closed to new replies.