Title: WP_Community_Events::__construct
Published: June 15, 2017
Last modified: August 20, 2026

---

# WP_Community_Events::__construct( int $user_id, false|array $user_location = false )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_community_events/__construct/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_community_events/__construct/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_community_events/__construct/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_community_events/__construct/?output_format=md#changelog)

Constructor for [WP_Community_Events](https://developer.wordpress.org/reference/classes/wp_community_events/).

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_community_events/__construct/?output_format=md#parameters)󠁿

 `$user_id`intrequired

WP user ID.

`$user_location`false|arrayoptional

Stored location data for the user. false to pass no location.

 * `description` string
 * The name of the location
 * `latitude` string
 * The latitude in decimal degrees notation, without the degree symbol. e.g.: 47.615200.
 * `longitude` string
 * The longitude in decimal degrees notation, without the degree symbol. e.g.: -
   122.341100.
 * `country` string
 * The ISO 3166-1 alpha-2 country code. e.g.: BR

Default:`false`

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_community_events/__construct/?output_format=md#source)󠁿

    ```php
    public function __construct( $user_id, $user_location = false ) {
    	$this->user_id       = absint( $user_id );
    	$this->user_location = $user_location;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-community-events.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/class-wp-community-events.php#L54)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/class-wp-community-events.php#L54-L57)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_community_events/__construct/?output_format=md#related)󠁿

| Uses | Description | 
| [absint()](https://developer.wordpress.org/reference/functions/absint/)`wp-includes/load.php` |

Converts a value to non-negative integer.

  |

| Used by | Description | 
| [wp_localize_community_events()](https://developer.wordpress.org/reference/functions/wp_localize_community_events/)`wp-includes/script-loader.php` |

Localizes community events data that needs to be passed to dashboard.js.

  | 
| [wp_ajax_get_community_events()](https://developer.wordpress.org/reference/functions/wp_ajax_get_community_events/)`wp-admin/includes/ajax-actions.php` |

Handles Ajax requests for community events

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_community_events/__construct/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.8.0](https://developer.wordpress.org/reference/since/4.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_community_events%2F__construct%2F)
before being able to contribute a note or feedback.