PluginProbe
Membership Plugin – Kadence Memberships / 2.1
Membership Plugin – Kadence Memberships v2.1
4.0.3 4.0.2 4.0.1 trunk 1.1 1.2 1.2.1 1.2.2 2.0 2.0.2 2.0.3 2.0.4 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.2.10 2.2.2 2.2.3 2.2.4 2.2.5 2.2.7 2.2.8 All 72 releases
restrict-content / includes / shortcodes.php

shortcodes.php in Membership Plugin – Kadence Memberships 2.1, at includes/shortcodes.php

48 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*******************************************
4 * Restrict Content Short Codes
5 *******************************************/
6
7 function restrict_shortcode( $atts, $content = null ) {
8 extract( shortcode_atts( array(
9 'userlevel' => 'none',
10 ), $atts ) );
11
12 global $rc_options;
13
14 if ($userlevel == 'admin' && current_user_can('switch_themes'))
15 {
16 return do_shortcode($content);
17 }
18 if ($userlevel == 'editor' && current_user_can('moderate_comments'))
19 {
20 return do_shortcode($content);
21 }
22 if ($userlevel == 'author' && current_user_can('upload_files'))
23 {
24 return do_shortcode($content);
25 }
26 if ($userlevel == 'contributor' && current_user_can('edit_posts'))
27 {
28 return do_shortcode($content);
29 }
30 if ($userlevel == 'subscriber' && current_user_can('read'))
31 {
32 return do_shortcode($content);
33 }
34 if ($userlevel == 'none' && is_user_logged_in())
35 {
36 return do_shortcode($content);
37 }
38 else return '<span style="color: red;">' . str_replace('{userlevel}', $userlevel, $rc_options['shortcode_message']) . '</span>';
39 }
40 add_shortcode('restrict', 'restrict_shortcode');
41
42 function rc_not_logged_in($atts, $content = null) {
43 if(!is_user_logged_in()) {
44 return do_shortcode( $content );
45 }
46 }
47 add_shortcode('not_logged_in', 'rc_not_logged_in');
48