[Resolved] Help with adding custom user fields to author archive
This thread is resolved. Here is a description of the problem and solution.
Problem:
A Layout is assigned to the author archive, and the client wants to display some custom user fields of the author at the top of that Layout, but nothing outputs when inserting the fields via Toolset shortcodes.
Solution:
The problem is that on an author archive the Layout doesn't know what post to retrieve data from all falls back to the $post object, but in the case of this client site which had no standard WordPress posts published there was no $post object.
Creating some standard WordPress posts (even if not used anywhere) fixed the issue.
This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
I'm not sure what your set-up is but I tested this locally and it worked as expected, so let me describe what I did.
I have a custom user field "Fantasy Name".
I created a custom WordPress archive to use for the author archive.
In the Loop Output editor section, immediately after the wpv-items-found shortcode I used the Fields and Views button to insert my custom user field, like so:
<h2>User Fantasy name inserted in custom archive: [types usermeta='fantasy-name' user_is_author='true'][/types]</h2>
I then created a Layout (you appear to be using Layouts) and assigned it to the author archive. My Layout contains a Visual Editor cell where I again inserted the custom field as shown below and then the archive cell created previously.
<h2>User Fantasy Name inserted into Layout Visual Editor cell: [types usermeta='fantasy-name' user_is_author='true'][/types]</h2>
You can see the results in the screenshot, where both types shortcodes correctly output the custom field value.
You have a custom WordPress archive called author archive.
But it is not being used, because you are using Layouts, and you have a Layout called default which is assigned to the author archive.
If Layouts is assigned to an archive it overrides any assignment of a custom archive you create at Toolset > WordPress Archives.
You need to create a new Layout that you assign to the author archive, and then insert an archive cell into the Layout and use the existing custom archive you already created.
Then the custom archive you created will actually be used, via the assigned Layout.
I did some more testing on your site and can see that the type fields are not outputting when in a Layout, although they do work if you disable Layouts and use the Views custom WordPress archive directly. (You'll note I've peppered the archive with a few extra types fields to confirm that the data is there to be output.)
But I cannot replicate it on my own test site, it seems to be an exception affecting your site only.
I tried disabling unrelated plugins, and switching to twentyseventeen, which didn't help.
I've take a copy of your site and am escalating this thread so it can be investigated further to determine why.
I'll update you again when I have something to report.
A Layout on the author archive doesn't know what post to retrieve fields from and so falls back to the $post object. It is failing in the particular case of your site because... you have no standard posts published, and so there is no $post object.
Inside the archive cell itself the custom post fields should output correctly, but elsewhere in the Layout they are not expected to because there is no current post.
But, if you publish a standard post, however unlikely that seems, you may see it working.
The reason I couldn't reproduce the issue on my local test site is because it is a standard install that still has the Hello World! post.