This simple code recipe creates a [pmpro_expiration_date] shortcode you can use in a page, post, widget, or pretty much anywhere on your site.

It shows the current logged in member’s expiration date or the expiration date for the user specified by the “user” attribute. The date is formatted per your site’s Settings > General > Date Format field. If there is no expiration or user, the shortcode displays “—“.


The Code Recipe

This code recipe requires a PMPro Plus Account or higher.

View Membership Options


How to Use

The shortcode [pmpro_expiration_date] can be used anywhere you would like to display the date. If you would like to add it to a widget area but it isn’t working, add this line of code to a helper PMPro Customizations plugin

// Enable the use of shortcodes in text widgets.
add_filter( 'widget_text', 'do_shortcode' );

I think a useful application of this shortcode would be to display a member’s expiration date on the bbPress Profile page. This recipe relies on our bbPress Add On setting to add the “Membership Level” section to the bbPress Profile, like this…

my_pmpro_bbpress_profile_expiration

This code recipe requires a PMPro Plus Account or higher.

View Membership Options


Comments (9)

Author’s gravatar

Hello,
We need to buy the “Core Account” to make this shortcode work ?
Thank you.

Reply
Author’s gravatar

Looks like you need a paid level to view the code. You might be able to find it by searching on gist.github.com if you can’t afford membership. The code is GPL and doesn’t require a license to run.

Reply
Author’s gravatar

Thank you very much for your answer.
Is it possible to set the date format in other language ? Or in numbers only like “2018-10-01” ?
Thank you very much for your help.

Author’s gravatar

Note that your shortcode in the web page text is actually running the shortcode described, rather than displaying what the shortcode should look like! I’m seeing this:

“This simple code recipe creates a — shortcode you can use in a page, post, widget, or pretty much anywhere on your site.”

Might want to fix this – perhaps use htmlentities to add the square brackets for the shortcode, so that you don’t actually run the shortcode.

Reply
Author’s gravatar

Thank you! I have just updated the post. We use the html entity for [ and ], but whenever you switch the editor from “text” to “visual” they swap for the character. Bugger!

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *