Support

Account

Home Forums Backend Issues (wp-admin) Submenu page with user form Reply To: Submenu page with user form

  • I do not know if this will work, it is just an untested theory.

    You can add a sub page to the user menu using an ACF options page. When setting up the options page set the “post_id” argument to something like “extra_user_options”.

    Create an acf/pre_load_post_id filter. This is an undocumented hook. It allows you to short-circuit ACF determination of the post ID. Here is the code in ACF

    
    function acf_get_valid_post_id( $post_id = 0 ) {
    
      // allow filter to short-circuit load_value logic
      $preload = apply_filters( 'acf/pre_load_post_id', null, $post_id );
      if ( $preload !== null ) {
        return $preload;
      }
      .................................
    

    If you return anything in the filter other than NULL then ACF will use that value for the post ID.

    In your filter check for the post ID you set up for the options page (i.e. “extra_user_options”) and if that is the post ID the return the correct post ID to cause ACF to use the user instead by returning "user_{$current_user_id}"

    If my theory is correct then ACF should load and save values to usermeta for the current user.