Support

Account

Home Forums General Issues Creating A Custom User Options Page?

Solving

Creating A Custom User Options Page?

  • I know I can use ACF to add custom fields to user profiles, however they display on the main user edit screens. And there’s a lot of stuff on there.

    How can I create a SECOND screen for user options that I can populate only with ACF fields? It can be in the WP admin, fed a user ID and I could manipulate my custom fields on that screen for a user without all the other usual fields cluttering things up.

    Give a guy a clue? 🙂

  • This has not been tested, but I think id should work. I’m not sure of all the setting here, but the following will only create an options page if the user is logged in and will save the values to the _usermeta table. Basically, it creates a single options page that uses a different post ID value depending on what user is logging in so the values are saved and retrieved from the current user. Other ACF functions should work as long as you provide the correct id when using them https://www.advancedcustomfields.com/resources/how-to-get-values-from-a-user/

    
    add_action('init', 'custom_user_options_page');
    function custom_user_options_page() {
      if (!is_user_loged_in()) {
        return;
      }
      $user_id = get_current_user_id();
      $post_id = 'user_'.$user_id;
      $args = array(
        'page_title' => 'User Options Page',
        'post_id' => $post_id,
      );
      acf_add_options_page($args);
    }
    
  • I wanted to add that, even as an admin you would not be able to see any values set this way for any user unless you create some other mechanism for showing these values. For example, you could apply the same field group to the options page and also the user profile page and set the location rules for the user profile page to only show them for admin users and this would give the admin the ability to edit them there while each user would need to go to the options page to make the edits.

  • Well, what I had in mind was a bit different. I would have an options screen that I could click into in admin, with a user ID passed in GET. Then, ideally, I’d be able to view/edit ACF fields on that screen and anything would be saved to that particular user’s user_meta so that I could access it on the front-end.

    Hope that makes sense.

    My big issue at the moment seems to me that when I create a new options page with acf_add_options_page(), it doesn’t show up in my dropdown of available options page with location rules. So, I’m sorta stuck.

  • I’ve created custom field to a category for example category image, category color etc.. how do i add these to my post template please?

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

You must be logged in to reply to this topic.