mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Fix shortcode within sho_content
This commit is contained in:
+14
-14
@@ -13,7 +13,7 @@ class UM_Shortcodes {
|
||||
add_shortcode('um_loggedin', array(&$this, 'um_loggedin'));
|
||||
add_shortcode('um_loggedout', array(&$this, 'um_loggedout'));
|
||||
add_shortcode('um_show_content', array(&$this, 'um_shortcode_show_content_for_role') );
|
||||
|
||||
|
||||
|
||||
add_filter('body_class', array(&$this, 'body_class'), 0);
|
||||
|
||||
@@ -514,38 +514,38 @@ class UM_Shortcodes {
|
||||
|
||||
/**
|
||||
* Shortcode: Show custom content to specific role
|
||||
*
|
||||
*
|
||||
* Show content to specific roles
|
||||
* [um_show_content roles='member'] <!-- insert content here --> [/um_show_content]
|
||||
* You can add multiple target roles, just use ',' e.g. [um_show_content roles='member,candidates,pets']
|
||||
*
|
||||
*
|
||||
* Hide content from specific roles
|
||||
* [um_show_content not='contributors'] <!-- insert content here --> [/um_show_content]
|
||||
* You can add multiple target roles, just use ',' e.g. [um_show_content roles='member,candidates,pets']
|
||||
*
|
||||
* @param array $atts
|
||||
*
|
||||
* @param array $atts
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
function um_shortcode_show_content_for_role( $atts = array() , $content = '' ) {
|
||||
|
||||
global $user_ID;
|
||||
|
||||
|
||||
if( ! is_user_logged_in() ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$a = shortcode_atts( array(
|
||||
'roles' => '',
|
||||
'not' => '',
|
||||
), $atts );
|
||||
|
||||
|
||||
um_fetch_user( $user_ID );
|
||||
|
||||
$current_user_role = um_user('role');
|
||||
|
||||
if( isset( $a['not'] ) && ! empty( $a['not'] ) && isset( $a['roles'] ) && ! empty( $a['roles'] ) ){
|
||||
return $content;
|
||||
return do_shortcode( $content );
|
||||
}
|
||||
|
||||
if( isset( $a['not'] ) && ! empty( $a['not'] ) ){
|
||||
@@ -553,21 +553,21 @@ class UM_Shortcodes {
|
||||
$not_in_roles = explode(",", $a['not'] );
|
||||
|
||||
if( is_array( $not_in_roles ) && ! in_array( $current_user_role, $not_in_roles ) ){
|
||||
return $content;
|
||||
return do_shortcode( $content );
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$roles = explode(",", $a['roles'] );
|
||||
|
||||
|
||||
if(is_array( $roles ) && in_array( $current_user_role, $roles ) ){
|
||||
return $content;
|
||||
return do_shortcode( $content );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user