Add or customize social links

I saw a similar post in this thread, but it wasn’t completely answered.

I want to either add or alter a social link so I can add GoogleMyBusiness links to vendor profiles. That other thread I could rename a link via hivepress/v1/social_links but he didn’t explain how. I did a search through the code examples and the Developer Docs and there’s nothing about it. So how do I properly change this social link (I’m thinking GooglePlay to alter)?

The easiest way to add custom social link is with this PHP snippet.

add_filter(
	'hivepress/v1/social_links',
	function($config){
		
		$config['custom_social_link'] = [
			'label' => 'Custom text',
		];
		
		return $config;
	},
	1000
);

It will add a social link option with a Custom text label and URL field type by default so users can save some URLs in this field.

To use another field type, please try this PHP snippet. For example, it is needed to save some phone numbers as a social link

add_filter(
	'hivepress/v1/social_links',
	function($config){
		
		$config['custom_social_link'] = [
			'label' => 'Custom text',
			'type' => 'phone',
		];
		
		return $config;
	},
	1000
);

Also, it is possible to change the prefix for the link. For example, it is needed to use mailto: prefix to send emails when an Email social link is used. So it is added prefix before the value of the social link

add_filter(
	'hivepress/v1/social_links',
	function($config){
		
		$config['custom_social_link'] = [
			'label' => 'Custom text',
			'type' => 'phone',
			'prefix' => 'custom_prefix',
		];
		
		return $config;
	},
	1000
);

It can require advanced customization, so if you are not familiar with the code customization, then please consider hiring someone for custom work https://fvrr.co/32e7LvY

1 Like

Thanks. I used the first example and it worked.

Does this add an attribute to the Vendors profile to add their social links??

These can be added via the Social Links extension, but the code snippet above allows adding new custom links (e.g. if some social media are not available for selection by default) to the list.

1 Like