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
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…
Comments (12)
I have set an expiry date for me (admin), but I don’t have a level. So it’s not working. How do I show the USER’s expiration date rather than the level’s expiration date?
Some users are comped up to a certain date, so looking for a level doesn’t work.
This recipe pulls the expiration date on the user, not the level. If your members are comped, they will have a level as well as an expiration date. The data is pulled from the DBPREFIX_pmpro_memberships_users table, which contains unique level information for each user’s active level.
How can add date field in front side so customer can select date for start memebership ?
Hi @kunjan,
For the time being, we do not currently have that feature available. If you would like you can get this feature custom coded for you by one of our Partner Developers
Hope this helps!
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.
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!
Hello,
We need to buy the “Core Account” to make this shortcode work ?
Thank you.
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.
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.
shortcode dont work for me
Sorry about that. Can you post to the member forums so we can get more info from you to help you set it up?