Last active
May 1, 2024 13:43
-
-
Save dwanjuki/6a6a61e3035257ee89f0ce2bb7fed1de to your computer and use it in GitHub Desktop.
Make website links on Member directory/profile pages open in new tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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