Last active
February 19, 2019 17:09
-
-
Save andrewlimaza/74b5888870f340391b1e51733dd92124 to your computer and use it in GitHub Desktop.
Shortcode to get Member RSS Key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Custom shortcode to get PMPro RSS Member Key. | |
| * Example 1: [pmpro_rss_key] This will return the key for current member. | |
| * Example 2: [pmpro_rss_key user_id="2"] This will return the key for user ID 2. | |
| * Copy from line 3 onwards into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| function pmprorss_shortcode_get_key( $atts ) { | |
| $attributes = shortcode_atts( array( | |
| 'user_id' => '' | |
| ), | |
| $atts | |
| ); | |
| if ( empty( $attributes['user_id'] ) ) { | |
| global $current_user; | |
| $user_id = $current_user->ID; | |
| }else{ | |
| $user_id = intval( $attributes['user_id'] ); | |
| } | |
| $key = pmpromrss_getMemberKey( $user_id ); | |
| return $key; | |
| } | |
| add_shortcode( 'pmpro_rss_key', 'pmprorss_shortcode_get_key' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment