Skip Navigation

[Resolved] Link name [wpv-post-author] to own profilepage

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

Problem:

This user had allowed his authors to Create there own profile pages in another CPT but wanted to link the author name of the posts that each author created to their own respective profiles.

Solution:
This can be easily done if the Post Title of the Authors profile page was created with just there name. This will mean that the author's profile page will be generated with a link containing their name.

So lets say i'm viewing this page.
@https://someurl.nl/training/compassietraining/ <- post that the author created When I click on the image it should link me to the profile of that trainer here : @https://someurl.nl/trainer/Marijke-van-Duinhoven/ <- Author's profile page So in order to achieve I created this custom shortcode to add a hypen between the trainers name and added it to the functions.php file.

// Add Shortcode
function add_dash( $atts ) {
    // Attributes
    $atts = shortcode_atts(
        array(
            'author' => '',
        ),
        $atts
    );
        $result = str_replace(" ", "-", $atts['author']);
        return $result ;
}
add_shortcode( 'add_dash', 'add_dash' );

Next wrap your author name in a link and passed the author shortcode into my custom shortcode.

This will result in a final code added to the page like this.

[php]
[wpv-post-author]

[php]

Please let me know if this helps.

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

Our next available supporter will start replying to tickets in about 2.28 hours from now. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by charlotteM-2 6 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#608875

On my site Trainers (CPT) make their own profile-page (via a CRED form) and they add Activities (CPT). In an activity you can see the name of the trainer (who posted this activity). I would like to make a link between this name of the Trainer and his/her profile-page.
I don’t succeed. Have read this article: https://toolset.com/forums/topic/wpv-post-link-or-types-fieldauthor-separator-types/
But it does not help.

Is there a similar example that we can see?
The page with the name is: hidden link

Hope you can help,
Have a nice day!
Charlotte

#608910

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Charlotte,

Thank you for contacting our support forum.

Do the users create a separate profile on a profile CPT or anything of such ?

Or do they just create a new user and then create the post.

Please let me know .
Thanks,
Shane

#608943

Hi Shane,

With a CRED-userform the trainer makes a user-account via [cred_field field='first_name' post='user' value='' urlparam='' class='form-control' output='bootstrap'] and the same with last_name.
Then with a CRED postform the trainer makes a profilepage wherein:
<div style="display:none;">
[cred_field field='user-id' post='trainer' value='[wpv-current-user info="id"]' urlparam='' class='form-control' output='bootstrap']
</div>
<div style="display:none;">
[cred_field field='post_title' post='trainer' value='[wpv-current-user info="firstname"] [wpv-current-user info="lastname"]' urlparam='' class='form-control' output='bootstrap']
</div>
<div>
<h2>[wpv-user field="user_firstname"] [wpv-user field="user_lastname"]</h2>
</div>
(I must say I don't understand the different names like: first_name (in the CRED-field); firstname and user_firstname), but it works fine.

Is this sufficient information?

Thanks,
Charlotte

#609107

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Charlotte,

It would be better if I took a look at it because I have an idea of how to achieve this.

The user should already be linked to his/her profile page if he was the user who created it.

Could you allow me to have admin access to the website so that I can check on the setup ?

Thanks,
Shane

#609850

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Charlotte,

Can you let me know which CPT is for the Activity. Also confirming that each trainer Creates his/her own profile.

So lets say i'm viewing this page.
hidden link

When I click on the image it should link me to the profile of that trainer here :
hidden link

So in order to achieve I created this custom shortcode to add a hypen between the trainers name and added it to the functions.php file.

// Add Shortcode
function add_dash( $atts ) {
	// Attributes
	$atts = shortcode_atts(
		array(
			'author' => '',
		),
		$atts
	);
	    $result = str_replace(" ", "-", $atts['author']);
	    return $result ;
}
add_shortcode( 'add_dash', 'add_dash' );

Next I wrapped your author name in a link and passed the author shortcode into my custom shortcode.

This will result in a final code added to the page like this.

<a href='<em><u>hidden link</u></em> author="[wpv-post-author]"]'>[wpv-post-author]</a>

Please let me know if this helps.
Thanks,
Shane

#609875

Wow Shane, thanks! It works.
I'm going to try and understand it.

A nice day to you,
Charlotte