Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimwhite/8d18b9a34ba8047d0fab4f162217b333 to your computer and use it in GitHub Desktop.
Save kimwhite/8d18b9a34ba8047d0fab4f162217b333 to your computer and use it in GitHub Desktop.
Display the user_url field as a clickable URL link on the PMPro Member Directory and Profile pages if the field was included in the shortcode's field attributes.
<?php
/**
* Show a clickable URL for the user_url profile field, with the word WEBSITE
* This will also stop the URL from being embedded with wp_oembed.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpromd_clickable_user_url( $value, $original_value, $field_name ) {
if ( 'user_url' === $field_name ) {
$value = ('<a href="'. $original_value . '" target="_blank">Website</a>' );
}
return $value;
}
add_filter( 'pmpromd_format_profile_field', 'my_pmpromd_clickable_user_url', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment