Skip Navigation

[Resolved] Display Author Archive page even without posts

This support ticket is created 7 years, 7 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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 6 replies, has 2 voices.

Last updated by Beda 7 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#423012

Hey there,

we're planning to use author archive as a profile page on our site. This basically works and we already display custom post types including post relations there thanks to the views plugin ??

The problem is: whenever a user doesn't have any posts yet nothing is displayed - not even the users information.

we're currently displaying this information with:

<p>[wpv-gravatar email="[wpv-post-author format='meta' meta='user_email']" raw="true"]</p>
<p>about: [wpv-post-author]</p>
<p>bio: [wpv-post-author format="meta" meta="description"] </p>
<p>Website: <a href="[wpv-post-author format="meta" meta="user_url"]">[wpv-post-author format="meta" meta="user_url"]</a></p>

Is there any chance to get this information also for users that don't have any posts yet and instead of displaying just nothing display some text like "no posts yet"?

Thanks

#423103

This is basically because the Loop is empty at that moment (where the User hasn't yet authored anything)

So what you need is to get that info outside the Loop.

Now, are you using PHP Archive Files, or do you use WordPress Archives created with Toolset?
I assume Views Archives, as in PHP you could only change the "if have posts" to an "if have / or not" statement.

Now, in Views WordPress Archives, they will always use the Loop as "if have".
It should, theoretically, return you a "No Items Found" message when you use a Views WordPress Archive and view an archive of a User that has NOT authored any post yet.

That means you could use that part of the Views Loop to customise this.

The part I mention is included in the Views Archive Loop within the ShortCodes:

[wpv-no-items-found]
  <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]

Does that help?

#423127

Hi,

I'm using the toolset wp archive view on the default url like /author/$username.

This is how my archive view for user profile (author archive) looks like:

<p>[wpv-gravatar email="[wpv-post-author format='meta' meta='user_email']" raw="true"]</p>
<p>User: [wpv-post-author]</p>
<p>Über mich: [wpv-post-author format="meta" meta="description"] </p>
<p>Website: <a href="[wpv-post-author format="meta" meta="user_url"]">[wpv-post-author format="meta" meta="user_url"]</a></p>

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop wrap="1" pad="true">
		[wpv-item index=1]
		<div class="row ">
			<div class="col-sm-12">[wpv-post-body view_template="Loop item in User Profile"]</div>
		</div>
		[wpv-item index=other]
			<div class="col-sm-12">[wpv-post-body view_template="Loop item in User Profile"]</div>
		[wpv-item index=pad]
			<div class="col-sm-12"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-12"></div>
		</div>
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

The code block on the top gets displayed but it doesn't get filled. It looks like there's no wpv-post-author info. That is also true within the wpv-no-items-found block.

How can I get the user info without there's something needed for authorship? Is there any common way to do user profiles?

#423130

That will not get filled as it's not in the Loop.

It's not even in the Layout to render.

As I elaborated, if there is no Post, there is nothing in the Loop, and you need to customize the "Nothing Found" message for this case.
There is no way to display something, if it does not exist.

#423131

That is, you can not do it with current Views HTML conditions.

You would need a Custom ShortCode/Functions that queries the current User's contents and if nothing is found, returns 0.
Then, you can use that in an HTML Conditional, to see if the output is greater than 0, and therefore output the infos you want.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#423161

What is the common way to do user profiles in the wp types context? As it seems to be quite officially supported to use CRED forms for creating user accounts and edit profiles there should also be a common way to display profiles. Probably we're on the completely wrong way by misusing the author archive for that if it doesn't work without posts?

Thanks for helping,
Frank

#423174

There is no real common way, as CRED User Forms are a relative new feature.

I can tell by my experience.

1. You do not nee great parametric Search interaction on your users, then you can use a View, that displays Users.

In that View, you can display almost anything of the User.

2. If you need complex search features through the USER meta and other data, you need a View that displays Posts.
I did that in past, by letting the user create a profile that is a POST, instead of a user.
Of course, the user is still a WordPress user, but when it comes to create an actual (front end) displayable Profile, I let him/here edit a post (the user isn't really aware of this if you do that smoothly)

3. The solution you use.
That will also work, with the drawback that it is a user Archive, intended to display contents of a user, not the user as a Profile.

4. We have a similar tutorial, that goes also over the account creation steps:
https://toolset.com/documentation/user-guides/cred-training-course/part-7-building-account-page-login-form/

It uses a page where the user sees information about him/her.

It's not what you would intended of a profile that I can see of another user, though.

The best way to achieve this, IMHO, is to mirror your user Profile Data to a Custom post Type.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.