Last active
April 29, 2020 16:23
-
-
Save cryptexvinci/2831827bc0ff23206a85fee1650b229e to your computer and use it in GitHub Desktop.
Display Ultimate Member field with a shortcode.
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 | |
| /* | |
| Code snippet of Plugin Ultimate Member | |
| URL: https://wordpress.org/plugins/ultimate-member/ | |
| */ | |
| // Display field data of Ultimate Member | |
| // e.g. [um_field_data userid="10' field="company_name"] | |
| add_shortcode( 'um_field_data', 'um_custom_field_shortcode' ); | |
| if ( ! function_exists( 'um_custom_field_shortcode' ) ) { | |
| function um_custom_field_shortcode( $atts = array() ){ | |
| $defaults = array( | |
| 'field' => NULL, | |
| 'userid' => NULL, | |
| ); | |
| $atts = wp_parse_args( $atts, $defaults ); | |
| extract( $atts ); | |
| ob_start(); | |
| $user_id = um_user($atts['userid']); | |
| um_fetch_user( $user_id ); | |
| $meta_value = um_user($atts['field']); | |
| print_r($meta_value); | |
| $shortcode_content = ob_get_contents(); | |
| ob_end_clean(); | |
| return $shortcode_content; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment