Add usermeta support to content locker shortcode

This commit is contained in:
Ultimate Member
2016-01-02 18:49:56 +02:00
parent 773749dec8
commit 8a95eda1ec
2 changed files with 13 additions and 2 deletions
+11
View File
@@ -120,6 +120,17 @@
$content = str_replace($args['tags'], $args['tags_replace'], $content);
}
$regex = '~\{([^}]*)\}~';
preg_match_all($regex, $content, $matches);
// Support for all usermeta keys
if ( isset( $matches[1] ) && is_array( $matches[1] ) && !empty( $matches[1] ) ) {
foreach( $matches[1] as $match ) {
$strip_key = str_replace('usermeta:','', $match );
$content = str_replace( '{' . $match . '}', um_user( $strip_key ), $content);
}
}
return $content;
}
+2 -2
View File
@@ -192,7 +192,7 @@ class UM_Shortcodes {
$args = wp_parse_args( $args, $defaults );
$args['lock_text'] = $this->convert_locker_tags( $args['lock_text'] );
//$args['lock_text'] = $this->convert_locker_tags( $args['lock_text'] );
if ( !is_user_logged_in() ) {
if ( $args['show_lock'] == 'no' ) {
@@ -202,7 +202,7 @@ class UM_Shortcodes {
$ultimatemember->shortcodes->load_template( 'login-to-view' );
}
} else {
echo do_shortcode( $this->convert_locker_tags( $content ) );
echo do_shortcode( $this->convert_locker_tags( wpautop( $content ) ) );
}
$output = ob_get_contents();