[buddypress-trac] [BuddyPress Trac] #8047: Some profile fields create empty links

buddypress-trac noreply at wordpress.org
Thu Jan 31 23:35:20 UTC 2019


#8047: Some profile fields create empty links
------------------------------+------------------------------
 Reporter:  shanebp           |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Extended Profile  |     Version:  4.1.0
 Severity:  normal            |  Resolution:
 Keywords:                    |
------------------------------+------------------------------
Description changed by shanebp:

Old description:

> The ''phone number'' and ''url'' fields create empty links if there is no
> data for that user.
> [ Other fields may also do that. ]
>
> For example, create a ''Phone Number'' profile field and set ''autolink''
> to disabled.
> Leave the field empty for all users.
> Then add this to bp-custom, after adjusting the args for
> ''xprofile_get_field_data'':
> {{{
> function xprofile_link_test() {
>
>         $field_value = xprofile_get_field_data( 3, 1, $multi_format =
> 'comma' );
>
>         var_dump( $field_value ); // string(36) ""
>
>         echo '<br>';
>
>         echo 'field value: ' . $field_value;
>
>         // the fields looks empty, but is really:
>         // <a href="tel://" rel="nofollow"></a>
>
> }
> add_action ( 'wp_head', 'xprofile_link_test' );
> }}}
>
> As you can see, it is impossible to test for an empty field value.
> And that can cause layout and formatting issues.
>
> Questions:
>
> 1. Why are empty links being created ?
>
> 2. Why is the ''autolink'' setting being ignored for some fields?  If
> there is field data for a member, that field is displayed as a link
> regardless of the state of the ''autolink'' setting.

New description:

 The ''phone number'' and ''url'' fields create empty links if there is no
 data for that user.
 [ Other fields may also do that. ]

 For example, create a ''Phone Number'' profile field and set ''autolink''
 to disabled.
 Leave the field empty for all users.
 Then add this to bp-custom, after adjusting the args for
 ''xprofile_get_field_data'':
 {{{
 function xprofile_link_test() {

         $field_value = xprofile_get_field_data( 3, 1, $multi_format =
 'comma' );

         var_dump( $field_value ); // string(36) ""

         echo '<br>';

         echo 'field value: ' . $field_value;

         // the fields looks empty, but is really:
         // <a href="tel://" rel="nofollow"></a>

 }
 add_action ( 'wp_head', 'xprofile_link_test' );
 }}}

 As you can see, it is impossible to test for an empty field value.
 And that can cause layout and formatting issues.

 The same thing happens in the members-loop.
 Switch the hook in the snip above from :
 {{{
 add_action ( 'wp_head', 'xprofile_link_test' );
 }}}
 to:
 {{{
 add_action ( 'bp_directory_members_item', 'xprofile_link_test' );
 }}}

 Questions:

 1. Why are empty links being created ?

 2. Why is the ''autolink'' setting being ignored for some fields?  If
 there is field data for a member, that field is displayed as a link
 regardless of the state of the ''autolink'' setting.

--

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8047#comment:1>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list