# Retrieve Custom User Meta from Expire Users Plugin \[RESOLVED\]

**URL:** <https://community.gravityforms.com/t/retrieve-custom-user-meta-from-expire-users-plugin-resolved/13223>\
**Category:** Get Help\
**Tags:** custom, gform\_field\_value, expire-users\
**Created:** [August 11, 2022, 9:21pm UTC](https://community.gravityforms.com/t/retrieve-custom-user-meta-from-expire-users-plugin-resolved/13223 "2022-08-11T21:21:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mginop](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/mginop/32/5645_2.png) [@mginop](https://community.gravityforms.com/u/mginop)\
**Post date:** [August 11, 2022, 9:21pm UTC](https://community.gravityforms.com/t/retrieve-custom-user-meta-from-expire-users-plugin-resolved/13223/1 "2022-08-11T21:21:36Z")

</div>

I need a nudge in the right direction. I’m using the User Registration Add-On and the Expire Users plugin to setup a simple membership site. Everything is setup and works fine except that I cannot seem to retrieve the “Expires Date” timestamp from the user meta stored in “\_expire\_user\_date” (created by the Expire Users plugin).

I have started a custom function below to compare the current date to the stored date, then add one year to the date (whichever is greater). This new “renewal date” will then be stored in a hidden field in the GF, populated dynamically. However the issue seems to be I cannot get the timestamp from “\_expire\_user\_date” as my $current\_expire\_date variable.

```auto
# Populate "Expiration Date" hidden field + 1 year on the membership renewal form
function timestamp_renewal_date() {
	// If it's not a logged-in user viewing this, never mind
	if( ! is_user_logged_in() ) :
		return;
	endif;
	// Get the "_expire_user_date" user meta value for the current user
	$current_expire_date = get_user_meta( get_current_user_id(), '_expire_user_date', true );
  $current_date = strtotime("now");
  if ($current_expire_date > $current_date) {
    $expire_date = date('d-m-Y H:i:s', $current_expire_date);
    return strtotime('+1 year',$expire_date);
  } else {
    return strtotime('+1 year');
  }
}
add_action( 'gform_field_value_renewaldate', 'timestamp_renewal_date' );

```

Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [August 12, 2022, 3:23pm UTC](https://community.gravityforms.com/t/retrieve-custom-user-meta-from-expire-users-plugin-resolved/13223/2 "2022-08-12T15:23:39Z")

</div>

Take a look at this documentation regarding Gravity Forms logging:

> **[Custom Logging Statements](https://docs.gravityforms.com/custom-logging-statements/#h-writing-to-the-core-log)**
>
> While Gravity Forms and its add-ons include numerous logging statements sometimes you may need to add more. This article explains how to add custom logging.

You will first need to enable Gravity Forms logging:

> **[Logging and Debugging](https://docs.gravityforms.com/logging-and-debugging/#h-enabling-logging)**
>
> For quite a while, enabling logging within Gravity Forms has been a go-to method for debugging any issues within Gravity Forms. As of Gravity Forms version 2.2, logging functionality has been moved from a separate add-on to becoming a core feature of...

Then add your own custom statements to your code to see what the value of `$current_expire_date` is when you retrieve it. It may be empty, or in a format you are not expecting.

After adding custom logging statements to your code and enabling logging, please test the form where the **renewaldate** field should be pre-populated, and then check the Gravity Forms Core log for your custom logging statements to see what is going on. Post the link to the log file if you need assistance figuring this out.

---

<div class="post-metadata">

**Author:** ![mginop](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/mginop/32/5645_2.png) [@mginop](https://community.gravityforms.com/u/mginop)\
**Post date:** [August 12, 2022, 6:24pm UTC](https://community.gravityforms.com/t/retrieve-custom-user-meta-from-expire-users-plugin-resolved/13223/3 "2022-08-12T18:24:59Z")

</div>

**Thank you Chris**! Thanks for introducing me to the logging and debugging in gravity forms. That is one of the best features of GF. It helped me determine that I was actually retrieving the expires date timestamp, but I had just been using the strtotime function incorrectly.

Below is my updated code in case anybody finds it useful in the future.

```auto
# Populate "Expiration Date" hidden field + 1 year for the membership renewal form
function timestamp_renewal_date() {
	// If it's not a logged-in user viewing this, never mind
	if( ! is_user_logged_in() ) :
		return;
	endif;
	// Get the "_expire_user_date" user meta value for the current user
	$current_expire_date = get_user_meta( get_current_user_id(), '_expire_user_date', true );
  $current_date = strtotime("now");
  if ($current_expire_date > $current_date) {
    $expire_date = date('d-m-Y H:i:s', $current_expire_date);
    return strtotime($expire_date . "+1 year");
  } else {
    return strtotime('+1 year');
  }
}
add_action( 'gform_field_value_renewaldate', 'timestamp_renewal_date' );

```

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [August 12, 2022, 6:31pm UTC](https://community.gravityforms.com/t/retrieve-custom-user-meta-from-expire-users-plugin-resolved/13223/4 "2022-08-12T18:31:50Z")

</div>

![this](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/5/577fb0e8eb29e54cf107eb2014c73d4ee59231b9.gif)

![Weekend](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/2/2e50de45777c55e788a7c07ee159df5d56082065.gif)

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [August 12, 2022, 6:31pm UTC](https://community.gravityforms.com/t/retrieve-custom-user-meta-from-expire-users-plugin-resolved/13223/5 "2022-08-12T18:31:55Z")

</div>


