bp_registration_options_ip_data

Filters the IP data into the user list table.

Description

bp_registration_options_ip_data( (int) $user_id ); 

Parameters (1)

0. $user_id (int)
ID of the user being listed.

Usage

  1. if ( !function_exists( 'bp_registration_options_ip_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-registration-options/includes/admin.php'; 
  3.  
  4. // ID of the user being listed. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_registration_options_ip_data($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/admin.php  
  1. function bp_registration_options_ip_data( $user_id ) { 
  2. $userip = trim( get_user_meta( $user_id, '_bprwg_ip_address', true ) ); 
  3. $response = wp_remote_get( 'https://freegeoip.net/json/' . $userip ); 
  4.  
  5. if ( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) { 
  6.  
  7. ?> 
  8. <div class="ip_address_wrap"> 
  9. <div class="alignleft"> 
  10. <?php 
  11. $data = json_decode( wp_remote_retrieve_body( $response ) ); 
  12. printf( 
  13. esc_html__( 'City: %s', 'bp-registration-options' ),  
  14. esc_html( $data->city ) 
  15. ); 
  16. printf( 
  17. esc_html__( 'IP: %s', 'bp-registration-options' ),  
  18. esc_html( $data->ip ) 
  19. ); 
  20. ?> 
  21. </div> 
  22. </div> 
  23. <?php 
  24. } else { 
  25. echo wpautop( $userip ); 
  26. } ?> 
  27. <?php