Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dwanjuki/6a6a61e3035257ee89f0ce2bb7fed1de to your computer and use it in GitHub Desktop.
Save dwanjuki/6a6a61e3035257ee89f0ce2bb7fed1de to your computer and use it in GitHub Desktop.
Make website links on Member directory/profile pages open in new tab
<?php
/**
* Make user-submitted website links on Member directory/profile pages open in new tab
* Add names of fields with URLs to line 13
*
* 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_add_target_blank_to_url_fields( $value, $original_value, $field_name ) {
$url_field_names = array( 'website' );
if( in_array( $field_name, $url_field_names ) ) {
$value = links_add_target( $value );
}
return $value;
}
add_filter( 'pmpromd_format_profile_field', 'my_pmpromd_add_target_blank_to_url_fields', 20, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment