Adding links to user profile

7.54K viewsCore
1

Can a user add links to their profile page? For example a URL link to their website, other web pages, etc. Somewhere in the description area I think would be best.

Yes it can be done easily. I will add my extended answer tomorrow.

@Rahul, so the user can add their link in the description area as a HTML link? I tried to do that, but it stripped out the HTML. Or, am I missing something.

I think for most low-tech people, it would be good to have separate fields so they can input their various URLs for website, blog, social media, etc. and after saving, these will appear as icons on the user profile page. No need to show the full URL because some could be long and messy. Just neat icons.

No, user cannot add nay link in description. I am thinking about it, for preventing spam links we are striping links.

In my case, adding links somewhere on the user profile is a must. However, I understand what you say regards spam. I certainly don’t want spam on my site or yours.

Perhaps separate fields might work and be easier to police. For example, I like how on a YouTube channel about page, you can add links and it automatically generates the correct social icon for the link. The icons are in the bottom right corner of the cover image, and it looks quite nice.

I saw on one site a way they minimized spam by providing specific fields for specific link types. For example, only allowing Facebook links in the Facebook field, and then it generates the Facebook icon for the front end.

Yes of course, custom fields are helpful in this case. Custom can be easily added to AnsPress profile but it not well documented at the moment. I will write documentation for adding custom user fields when I get some time.

Great. It would have to be done in some way that doesn’t require any coding, otherwise I’m lost. Would be nice if it is some kind of setting we can select.

Don’t worry just copy paste task

Ah, so, would that mean the change is lost when I next update the plugin?

of course not.

1

I hope you mean adding a custom link in user menu ? if yes you can simply add this filter:

function my_ap_user_link($links){

	if(is_user_logged_in()){
		$links['orders'] = array( 'slug' => 'orders', 'title' => __('My Orders'), 'link' => home_url( 'orders' ), 'order' => 1, 'show_in_menu' => false, 'public' => false, 'class' => 'icon-download');
		$links['logout'] = array( 'slug' => 'logout', 'title' => __('Logout'), 'link' => wp_logout_url( ), 'order' => 100, 'show_in_menu' => false, 'public' => true, 'class' => 'icon-lock');
	}

	return $links;
}
add_filter( 'ap_user_menu', 'my_ap_user_link' );

This is good but I actually meant putting links on the User Profile page. Will amend question.

Whree should i copy paste these codes ?

@aliirawan
please copy&paste at end of “wp-content/plugins/anspress/theme/default/function.php”
or in
“wp-content/themes/YOUR THEME/function.php”