Skip Navigation

[Resolved] Rendering the Correct User Profile Values

This thread is resolved. Here is a description of the problem and solution.

Problem:

I am trying to:
* Use the "WordPress Archive / Author archive" as a "VIEW" for each Author Profile.
* Remove extra space above Profile Picture
* Remove default about "Username" data on top.
* Make URL to Author Profile, NOT include their username maybe custom or company value.

I expected to see:
Metadata about that user.

Instead, I got:
Metadata about the main Administrator/Current Logged in user.

Solution:

It is expected result, the views shortcode [wpv-user] will output the current user information, in your case it needs some custom codes, for example:
1) Create a shortcode [archive-author-id] to get the user's ID of the archive author page, by adding below codes into your theme/theme-functions.php:

add_shortcode('archive-author-id', 'archive_author_id_func');
function archive_author_id_func($atts, $content){
    $res = 0;
    $author_name = get_query_var( 'author_name' );
    if($author_name){
        $author = get_user_by( 'slug', $author_name);
        $res = $author->ID;
    }
    return $res;
}

2) Dashborad-> Toolset-> Settings-> Front-end Content, in option "Third-party shortcode arguments", add above shortcode name: archive-author-id

3) Modify the codes you mentioned above
Change the Views shortcode from:
[wpv-user field="profile_picture"]
To:
[wpv-user field="profile_picture" id="[archive-author-id]"]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

Types shortcode, from:
[types usermeta='phone'][/types]
To:
[types usermeta='phone' user_id="[archive-author-id]"][/types]
https://toolset.com/documentation/customizing-sites-using-php/functions/

You will need to manually modify those shortcodes one by one, I just only setup some example in your website, for your reference.

Relevant Documentation:

https://toolset.com/documentation/customizing-sites-using-php/functions/

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by Luo Yang 6 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#606588

I am trying to:
* Use the "WordPress Archive / Author archive" as a "VIEW" for each Author Profile.
* Remove extra space above Profile Picture
* Remove default about "Username" data on top.
* Make URL to Author Profile, NOT include their username maybe custom or company value.

Link to a page where the issue can be seen:
hidden link
I expected to see:
Metadata about that user.

Instead, I got:
Metadata about the main Administrator/Current Logged in user.

Here is my current code:

<table width="100%">
<thead>
<tr>
<td>

[wpv-user field="profile_picture"]<br>
<b>[wpv-user field="user_firstname"] [wpv-user field="user_lastname"]</b><br>  
[types usermeta='phone'][/types]<br>
[wpv-user field="user_email"]<br>  
<b>Member Since:</b> [wpv-user field="user_registered"]<br> 

</td>
<td>

<b>COMPANY INFO:</b><br>
[types usermeta='company'][/types]<br>
[types usermeta='slogan'][/types]<br>
[wpv-user field="user_url"]<br>
[types usermeta='company-logo' alt='%%ALT%%' title='%%TITLE%%' size='medium' align='left' resize='pad' padding_color='transparent'][/types]<br>

</td>
</tr>
</thead>
</table>
[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
	[/wpv-no-items-found]
[wpv-layout-end]
#606661

Dear theW,

It is expected result, the views shortcode [wpv-user] will output the current user information, in your case it needs some custom codes, for example:
1) Create a shortcode [archive-author-id] to get the user's ID of the archive author page, by adding below codes into your theme/theme-functions.php:

add_shortcode('archive-author-id', 'archive_author_id_func');
function archive_author_id_func($atts, $content){
	$res = 0;
	$author_name = get_query_var( 'author_name' );
	if($author_name){
		$author = get_user_by( 'slug', $author_name);
		$res = $author->ID;
	}
	return $res;
}

2) Dashborad-> Toolset-> Settings-> Front-end Content, in option "Third-party shortcode arguments", add above shortcode name: archive-author-id
hidden link

3) Modify the codes you mentioned above
hidden link
Change the Views shortcode from:
[wpv-user field="profile_picture"]
To:
[wpv-user field="profile_picture" id="[archive-author-id]"]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

Types shortcode, from:
[types usermeta='phone'][/types]
To:
[types usermeta='phone' user_id="[archive-author-id]"][/types]
https://toolset.com/documentation/customizing-sites-using-php/functions/

You will need to manually modify those shortcodes one by one, I just only setup some example in your website, for your reference.

#606930

Thank you so much for your help Luo Yang,
I appreciate the step by step instructions very much!

Since any code I put in my Theme's Functions PHP will get deleted when the Theme gets updated, I wouln't want to put it there, so I added the code you kindly provided to my Custom Functions plugin here:
hidden link

add_shortcode('archive-author-id', 'archive_author_id_func');
function archive_author_id_func($atts, $content){
    $res = 0;
    $author_name = get_query_var( 'author_name' );
    if($author_name){
        $author = get_user_by( 'slug', $author_name);
        $res = $author->ID;
    }
    return $res;
}

But I got a Fatal Error:
Fatal error: Cannot redeclare archive_author_id_func() (previously declared in /home3/dlhg/GSCM.updatez.me/wp-content/plugins/AAA-Custom-Functions/AAA-Custom-Functions.php:23) in /home3/dlhg/GSCM.updatez.me/wp-content/themes/themify-ultra/theme-functions.php on line 3001

#606963

You will need to move the custom PHP codes from your theme/theme-functions.php to the plugin file AAA-Custom-Functions.php, please test again, check if it is fixed. thanks

#607230
More.png

Awesome!

All the Profile Field Values are displaying correctly this time!
Thanks a lot Luo.

This is my code:

<table width="100%">
<thead>
<tr>
<td>
 
[wpv-user field="profile_picture" id="[archive-author-id]"]<br>
<b>[wpv-user field="user_firstname" id="[archive-author-id]"] [wpv-user field="user_lastname" id="[archive-author-id]"]</b><br>  
[types usermeta='phone'][/types]<br>
[wpv-user field="user_email" id="[archive-author-id]"]<br>  
<b>Member Since:</b> [wpv-user field="user_registered" id="[archive-author-id]"]<br> 

</td>
<td>

<b>COMPANY INFO:</b><br>
[types usermeta='company'][/types]<br>
[types usermeta='slogan'][/types]<br>
[wpv-user field="user_url" id="[archive-author-id]"]<br>
[types usermeta='company-logo' alt='%%ALT%%' title='%%TITLE%%' size='medium' align='left' resize='pad' padding_color='transparent'][/types]<br>

</td>
</tr>
</thead>
</table>
[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
	[/wpv-no-items-found]
[wpv-layout-end]

There where no errors this time.
I guess, you had previously added the same code in the theme/theme-functions.php?
Or is it that when I update my Ultra Theme, would I need to remove any code, to not get that error again?
Please let me know.

Also, is it possible to have a field where users can choose what their Profile URL is?

#607410

Q1) I guess, you had previously added the same code in the theme/theme-functions.php?
Yes, I had put the codes into theme/theme-functions.php, since it has been moved to file AAA-Custom-Functions.php, so there should be any problem when you upgrade your theme

Q2) Also, is it possible to have a field where users can choose what their Profile URL is?
There isn't such a built-in feature within Toolset plugins, you might need to try other plugins, for example:
https://wordpress.org/plugins/search/author+archive+URL/

#607412
607230-More.png

Oh great, thanks a lot Luo.

Looks like one of those plugins might just do the trick...

I've been looking around in the "WP Author Archive" settings for a way to remove/change the default text, but I can't find the code that's generating this.

Could you please let me know how to do those modifications?
Please see my screenshot attached.

#607417

It is a new question, please check your theme files, for example author.php, find the codes for outputting "the default text", remove it, and test again.

If you still need assistance for it, please create new thread for the new question, that will help other users to find the answers.

#608405

Ok, thanks again!

#608423

You are welcome