Advertisement
rdusnr

Untitled

May 18th, 2017
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.23 KB | None | 0 0
  1. <?php
  2. /**
  3. * Membership functions
  4. *
  5. * @package WordPress
  6. * @subpackage Kleo
  7. * @author SeventhQueen <themesupport@seventhqueen.com>
  8. * @since Kleo 1.0
  9. */
  10.  
  11. //options array for restrictions: kleo_restrict_sweetdate
  12. global $kleo_pay_settings;
  13. $kleo_pay_settings = array (
  14. array(
  15. 'title' => __('Members directory restriction','kleo_framework'),
  16. 'front' => __('View members directory','kleo_framework'),
  17. 'name' => 'members_dir'
  18. ),
  19. array(
  20. 'title' => __('Restrict viewing other profiles','kleo_framework'),
  21. 'front' => __('View members profile','kleo_framework'),
  22. 'name' => 'view_profiles'
  23. ),
  24. array(
  25. 'title' => __('Groups directory restriction','kleo_framework'),
  26. 'front' => __('Access group directory','kleo_framework'),
  27. 'name' => 'groups_dir'
  28. ),
  29. array(
  30. 'title' => __('Group page restriction','kleo_framework'),
  31. 'front' => __('Access to groups','kleo_framework'),
  32. 'name' => 'view_groups'
  33. ),
  34. array(
  35. 'title' => __('Site activity restriction','kleo_framework'),
  36. 'front' => __('View site activity','kleo_framework'),
  37. 'name' => 'show_activity'
  38. ),
  39. array(
  40. 'title' => __('Sending private messages restriction','kleo_framework'),
  41. 'front' => __('Send Private messages','kleo_framework'),
  42. 'name' => 'pm'
  43. ),
  44. array(
  45. 'title' => __('Restrict users from adding media to their profile using rtMedia','kleo_framework'),
  46. 'front' => __('Add media to your profile','kleo_framework'),
  47. 'name' => 'add_media'
  48. )
  49. );
  50.  
  51. $kleo_pay_settings = apply_filters('kleo_pmpro_level_restrictions', $kleo_pay_settings);
  52.  
  53. /**
  54. * Get saved membership settings
  55. * @return array
  56. * @since 2.0
  57. */
  58. function kleo_memberships($theme='')
  59. {
  60. $restrict_options = sq_option('membership');
  61.  
  62. return $restrict_options;
  63. }
  64.  
  65. if (!function_exists('kleo_pmpro_restrict_rules')):
  66. /**
  67. * Applies restrictions based on the Theme options -> Memberships
  68. * @return void
  69. * @since 2.0
  70. */
  71. function kleo_pmpro_restrict_rules()
  72. {
  73. //if PMPRO is not activated
  74. if (! function_exists('pmpro_url')) {
  75. return;
  76. }
  77.  
  78. //if buddypress is not activated
  79. if (!function_exists('bp_is_active')) {
  80. return;
  81. }
  82.  
  83. //full current url
  84. $actual_link = kleo_full_url();
  85.  
  86. //our request uri
  87. $home_url = home_url();
  88.  
  89. //WPML support
  90. if (defined('ICL_SITEPRESS_VERSION'))
  91. {
  92. global $sitepress;
  93. $home_url = $sitepress->language_url( ICL_LANGUAGE_CODE );
  94. }
  95.  
  96. $home_url = str_replace("www.","",$home_url);
  97.  
  98. $uri = str_replace(untrailingslashit($home_url),"",$actual_link);
  99.  
  100. //restriction match array
  101. $final = array();
  102.  
  103. $allowed_chars = apply_filters('kleo_pmpro_allowed_chars', "a-z 0-9~%.:_\-");
  104. $restrict_options = kleo_memberships();
  105. $members_slug = str_replace('/', '\/', bp_get_members_root_slug());
  106.  
  107.  
  108.  
  109. /*-----------------------------------------------------------------------------------*/
  110. /* Preg match rules
  111. /*-----------------------------------------------------------------------------------*/
  112.  
  113. //members directory restriction rule
  114. $final["/^\/".$members_slug."\/?$/"] = array('name' => 'members_dir', 'type' => $restrict_options['members_dir']['type'], 'levels' => isset($restrict_options['members_dir']['levels'])?$restrict_options['members_dir']['levels']:array());
  115.  
  116. if (function_exists('bp_get_groups_root_slug'))
  117. {
  118. $groups_slug = str_replace('/', '\/', bp_get_groups_root_slug());
  119.  
  120. //groups directory restriction rule
  121. $final["/^\/".$groups_slug."\/?$/"] = array('name' => 'groups_dir', 'type' => $restrict_options['groups_dir']['type'], 'levels' => isset($restrict_options['groups_dir']['levels'])?$restrict_options['groups_dir']['levels']:array());
  122.  
  123. //groups single page restriction rule
  124. $final["/^\/".$groups_slug."\/[".$allowed_chars."\/]+\/?$/"] = array('name' => 'view_groups', 'type' => $restrict_options['view_groups']['type'], 'levels' => isset($restrict_options['view_groups']['levels'])?$restrict_options['view_groups']['levels']:array());
  125. }
  126.  
  127. if (function_exists('bp_get_activity_root_slug'))
  128. {
  129. $activity_slug = str_replace('/', '\/', bp_get_activity_root_slug());
  130. //activity page restriction rule
  131. $final["/^\/".$activity_slug."\/?$/"] = array('name' => 'show_activity', 'type' => $restrict_options['show_activity']['type'], 'levels' => isset($restrict_options['show_activity']['levels'])?$restrict_options['show_activity']['levels']:array());
  132. }
  133.  
  134. /* You can add extra restrictions using this filter */
  135. $final = apply_filters('kleo_pmpro_match_rules',$final);
  136.  
  137. //no redirection for super-admin
  138. if (is_super_admin())
  139. {
  140. return false;
  141. }
  142. elseif (is_user_logged_in()) //only if logged in
  143. {
  144. //restrict media
  145. if(preg_match("/^\/".$members_slug."\/". bp_get_loggedin_user_username()."\/media\/?/", $uri)
  146. || preg_match("/^\/".$members_slug."\/". bp_get_loggedin_user_username()."\/album\/?/", $uri)
  147. )
  148. {
  149. kleo_check_access('add_media', $restrict_options);
  150. }
  151. //restrict private messages
  152. elseif(preg_match("/^\/".$members_slug."\/". bp_get_loggedin_user_username()."\/messages\/compose\/?/", $uri)
  153. || preg_match("/^\/".$members_slug."\/". bp_get_loggedin_user_username()."\/messages\/view\/[".$allowed_chars."\/]?\/?/", $uri)
  154. )
  155. {
  156. kleo_check_access('pm', $restrict_options);
  157. }
  158.  
  159. /* Add other restrictions for own profile */
  160. do_action('kleo_pmro_extra_restriction_before_my_profile',$restrict_options); /* Deprecated */
  161. do_action('kleo_pmpro_extra_restriction_before_my_profile',$restrict_options);
  162.  
  163. //allow me to view other parts of my profile
  164. if (bp_is_my_profile())
  165. {
  166. return false;
  167. }
  168. }
  169.  
  170. //members single profile restriction rule
  171. if (bp_is_user()) {
  172. kleo_check_access('view_profiles', $restrict_options);
  173. }
  174.  
  175. //loop through remaining restrictions
  176. foreach($final as $rk => $rv)
  177. {
  178. if(preg_match($rk, $uri))
  179. {
  180. kleo_check_access($rv['name'], $restrict_options);
  181. }
  182. }
  183.  
  184. do_action( 'kleo_pmro_extra_restriction_rules', $restrict_options ); /* Deprecated */
  185. do_action( 'kleo_pmpro_extra_restriction_rules', $restrict_options );
  186. }
  187. endif;
  188.  
  189. if (! is_admin()) {
  190. add_action("init", "kleo_pmpro_restrict_rules");
  191. }
  192.  
  193. if (!function_exists('kleo_check_access')) :
  194. /**
  195. * Checks $area for applied restrictions based on user status(logged in, membership level)
  196. * and does the proper redirect
  197. * @global object $current_user
  198. * @param string $area
  199. * @param array $restrict_options
  200. * @param boolean $return Whether to just return true if the restriction should be applied
  201. *
  202. * @return boolean|void
  203. * @since 2.0
  204. */
  205. function kleo_check_access($area, $restrict_options=null, $return = false)
  206. {
  207. global $current_user;
  208.  
  209. if (!$restrict_options) {
  210. $restrict_options = kleo_memberships();
  211. }
  212.  
  213. if (pmpro_url("levels")) {
  214. $default_redirect = pmpro_url("levels");
  215. }
  216. else {
  217. $default_redirect = bp_get_signup_page();
  218. }
  219. $default_redirect = apply_filters('kleo_pmpro_url_redirect', $default_redirect);
  220.  
  221. //no restriction
  222. if ($restrict_options[$area]['type'] == 0)
  223. {
  224. return false;
  225. }
  226.  
  227. //restrict all members -> go to home url
  228. if ($restrict_options[$area]['type'] == 1)
  229. {
  230. wp_redirect(apply_filters('kleo_pmpro_home_redirect',home_url()));
  231. exit;
  232. }
  233.  
  234. //is a member
  235. if (isset($current_user->membership_level) && $current_user->membership_level->ID) {
  236.  
  237. //if restrict my level
  238. if ($restrict_options[$area]['type'] == 2 && isset($restrict_options[$area]['levels']) && is_array($restrict_options[$area]['levels']) && !empty($restrict_options[$area]['levels']) && pmpro_hasMembershipLevel($restrict_options[$area]['levels']) )
  239. {
  240. return kleo_pmpro_return_restriction($return, $default_redirect);
  241. exit;
  242. }
  243.  
  244. //logged in but not a member
  245. } else if (is_user_logged_in()) {
  246. if ($restrict_options[$area]['type'] == 2 && isset($restrict_options[$area]['not_member']) && $restrict_options[$area]['not_member'] == 1)
  247. {
  248. return kleo_pmpro_return_restriction($return, $default_redirect);
  249. exit;
  250. }
  251. }
  252. //not logged in
  253. else {
  254. if ($restrict_options[$area]['type'] == 2 && isset($restrict_options[$area]['guest']) && $restrict_options[$area]['guest'] == 1)
  255. {
  256. return kleo_pmpro_return_restriction($return, $default_redirect);
  257. exit;
  258. }
  259. }
  260. }
  261. endif;
  262.  
  263. /**
  264. * Calculate if we want to apply the redirect or just return true when restriction is applied
  265. *
  266. * @param boolean $return
  267. * @param string $default_redirect
  268. * @return boolean
  269. *
  270. * @since 4.0.3
  271. */
  272. function kleo_pmpro_return_restriction($return = false, $default_redirect = null) {
  273. $custom_link = apply_filters( 'kleo_pmpro_return_restriction_custom_link', $default_redirect );
  274. if ($return === false) {
  275. wp_redirect($custom_link);
  276. exit;
  277. } else {
  278. return true;
  279. }
  280. }
  281.  
  282. if (!function_exists('kleo_membership_info')) :
  283. /**
  284. * Add membership info next to profile page username
  285. * @since 2.0
  286. */
  287. function kleo_membership_info()
  288. {
  289. global $membership_levels,$current_user;
  290. if (! $membership_levels) {
  291. return;
  292. }
  293.  
  294. if (bp_is_my_profile())
  295. {
  296. if (isset($current_user->membership_level) && $current_user->membership_level->ID)
  297. {
  298. echo '<a href="'.pmpro_url("account").'"><span class="label radius pmpro_label">'.$current_user->membership_level->name.'</span></a>';
  299. }
  300. else
  301. {
  302. echo '<a href="'.pmpro_url("levels").'"><span class="label radius pmpro_label">'.__("Upgrade account",'kleo_framework').'</span></a>';
  303. }
  304. }
  305. }
  306. endif;
  307. add_action('bp_before_member_header_meta', 'kleo_membership_info');
  308.  
  309.  
  310. /*
  311. * Some template hacking because if you are using child theme
  312. * PMPRO fails to get parent templates
  313. */
  314.  
  315. //remove default function
  316. remove_action("wp", "pmpro_wp", 1);
  317.  
  318. //this code runs after $post is set, but before template output
  319. function pmpro_wp_custom()
  320. {
  321. if(!is_admin())
  322. {
  323. global $post, $pmpro_pages, $pmpro_page_name, $pmpro_page_id, $pmpro_body_classes;
  324.  
  325. //no pages yet?
  326. if(empty($pmpro_pages))
  327. return;
  328.  
  329. //run the appropriate preheader function
  330. foreach($pmpro_pages as $pmpro_page_name => $pmpro_page_id)
  331. {
  332. if(!empty($post->post_content) && strpos($post->post_content, "[pmpro_" . $pmpro_page_name . "]") !== false)
  333. {
  334. //preheader
  335. require_once(PMPRO_DIR . "/preheaders/" . $pmpro_page_name . ".php");
  336.  
  337. //add class to body
  338. $pmpro_body_classes[] = "pmpro-" . str_replace("_", "-", $pmpro_page_name);
  339.  
  340. //shortcode
  341. function pmpro_pages_shortcode($atts, $content=null, $code="")
  342. {
  343. global $pmpro_page_name;
  344. ob_start();
  345. if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/pages/" . $pmpro_page_name . ".php"))
  346. include(get_stylesheet_directory() . "/paid-memberships-pro/pages/" . $pmpro_page_name . ".php");
  347. elseif(file_exists(get_template_directory() . "/paid-memberships-pro/pages/" . $pmpro_page_name . ".php"))
  348. include(get_template_directory() . "/paid-memberships-pro/pages/" . $pmpro_page_name . ".php");
  349. else
  350. include(PMPRO_DIR . "/pages/" . $pmpro_page_name . ".php");
  351.  
  352. $temp_content = ob_get_contents();
  353. ob_end_clean();
  354. return apply_filters("pmpro_pages_shortcode_" . $pmpro_page_name, $temp_content);
  355. }
  356. add_shortcode("pmpro_" . $pmpro_page_name, "pmpro_pages_shortcode");
  357. break; //only the first page found gets a shortcode replacement
  358. }
  359. }
  360. }
  361. }
  362. add_action("wp", "pmpro_wp_custom", 1);
  363.  
  364.  
  365. //checkout shortcode override
  366. remove_shortcode("pmpro_checkout", "pmpro_checkout_shortcode");
  367. function pmpro_checkout_shortcode_custom($atts, $content=null, $code="")
  368. {
  369. ob_start();
  370. if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/pages/checkout.php")) {
  371. include(get_stylesheet_directory() . "/paid-memberships-pro/pages/checkout.php");
  372. }
  373. elseif(file_exists(get_template_directory() . "/paid-memberships-pro/pages/checkout.php")) {
  374. include(get_template_directory() . "/paid-memberships-pro/pages/checkout.php");
  375. }
  376. else {
  377. include(PMPRO_DIR . "/pages/checkout.php");
  378. }
  379. $temp_content = ob_get_contents();
  380. ob_end_clean();
  381. return apply_filters("pmpro_pages_shortcode_checkout", $temp_content);
  382. }
  383. add_shortcode("pmpro_checkout", "pmpro_checkout_shortcode_custom");
  384.  
  385.  
  386. /**
  387. * BP Profile Message UX compatibility
  388. * @since 4.0.3
  389. */
  390. function kleo_bp_profile_message_ux_send_private_message() {
  391. if ( isset( $_POST['private_message_content'] ) && ! empty( $_POST['private_message_content'] ) ) {
  392. $content_restricted = __("You aren't allowed to perform this action", "kleo_framework");
  393.  
  394. if (kleo_check_access('pm', null, true)) {
  395. bp_core_add_message( $content_restricted, 'error' );
  396. bp_core_redirect( bp_displayed_user_domain() );
  397. }
  398. }
  399. }
  400.  
  401. add_action( 'wp', 'kleo_bp_profile_message_ux_send_private_message', 2 );
  402.  
  403.  
  404. /**
  405. * Options settings callback function
  406. *
  407. * @global array $kleo_pay_settings
  408. * @global object $wpdb
  409. * @param string $field
  410. * @param array $value
  411. */
  412. function pmpro_data_set($field, $value) {
  413.  
  414. //print_r($value);
  415. global $kleo_pay_settings, $wpdb;
  416. $sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ";
  417. $levels = $wpdb->get_results($sqlQuery, OBJECT);
  418. echo '<table class="membership-settings">';
  419. foreach ($kleo_pay_settings as $pays) :
  420. ?>
  421. <tr>
  422. <td scope="row" valign="top">
  423. <label for="<?php echo $pays['name'];?>"><strong><?php echo $pays['title'];?></strong></label>
  424. </td>
  425. <td>
  426. <select id="<?php echo $pays['name'];?>" name="<?php echo 'kleo_'. KLEO_DOMAIN.'['.$field['id'].']';?>[<?php echo $pays['name'];?>][type]" onchange="pmpro_update<?php echo $pays['name'];?>TRs();">
  427. <option value="0" <?php if(!isset($value[$pays['name']]['type'])) { ?>selected="selected"<?php } ?>><?php _e('No', 'pmpro');?></option>
  428. <option value="1" <?php if(isset($value[$pays['name']]['type']) && $value[$pays['name']]['type'] == 1) { ?>selected="selected"<?php } ?>><?php _e('Restrict All Members', 'pmpro');?></option>
  429. <option value="2" <?php if(isset($value[$pays['name']]['type']) && $value[$pays['name']]['type'] == 2) { ?>selected="selected"<?php } ?>><?php _e('Restrict Certain Levels', 'pmpro');?></option>
  430. </select>
  431. </td>
  432. </tr>
  433. <tr id="<?php echo $pays['name'];?>levels_tr" <?php if(isset($value[$pays['name']]['type']) && $value[$pays['name']]['type'] != 2) { ?>style="display: none;"<?php } ?>>
  434. <td scope="row" valign="top">
  435. <label for="<?php echo 'kleo_'. KLEO_DOMAIN.'['.$field['id'].']';?>[<?php echo $pays['name'];?>][levels][]"><?php _e('Choose Levels to Restrict', 'pmpro');?>:</label>
  436. </td>
  437. <td>
  438. <div class="checkbox_box" <?php if(count($levels) > 3) { ?>style="height: 100px; overflow: auto;"<?php } ?>>
  439. <div class="clickable"><label><input type="checkbox" id="<?php echo $pays['name'];?>levels_guest" name="<?php echo 'kleo_'. KLEO_DOMAIN.'['.$field['id'].']';?>[<?php echo $pays['name'];?>][guest]" value="1" <?php if(isset($value[$pays['name']]['guest']) && $value[$pays['name']]['guest'] == 1) { ?>checked="checked"<?php } ?>> <?php echo __("Not logged in","kleo_framework");?></label></div>
  440. <div class="clickable"><label><input type="checkbox" id="<?php echo $pays['name'];?>levels_not_member" name="<?php echo 'kleo_'. KLEO_DOMAIN.'['.$field['id'].']';?>[<?php echo $pays['name'];?>][not_member]" value="1" <?php if(isset($value[$pays['name']]['not_member']) && $value[$pays['name']]['not_member'] == 1) { ?>checked="checked"<?php } ?>> <?php echo __("Not members","kleo_framework");?></label></div>
  441. <?php
  442. if (isset($value[$pays['name']]['levels'])) {
  443. if(!is_array($value[$pays['name']]['levels']))
  444. $value[$pays['name']]['levels'] = explode(",", $value[$pays['name']]['levels']);
  445. }
  446. else {
  447. $value[$pays['name']]['levels'] = array();
  448. }
  449. foreach($levels as $level)
  450. {
  451. ?>
  452. <div class="clickable"><label><input type="checkbox" class="kleo-no-click-event" id="<?php echo $pays['name'];?>levels_<?php echo $level->id; ?>" name="<?php echo 'kleo_'. KLEO_DOMAIN.'['.$field['id'].']'; ?>[<?php echo $pays['name']; ?>][levels][]" value="<?php echo $level->id; ?>" data-initval="<?php echo $level->id; ?>" <?php if( in_array( $level->id, $value[$pays['name']]['levels'] ) ) { ?>checked="checked"<?php } ?>> <?php echo $level->name?></label></div>
  453. <?php
  454. }
  455. ?>
  456. </div>
  457. </td>
  458. </tr>
  459. <tr class="bottom-border">
  460. <td scope="row" valign="top">
  461. <label><?php _e("Show field in memberships table","kleo_framework");?></label>
  462. </td>
  463. <td>
  464. <select name="<?php echo 'kleo_'. KLEO_DOMAIN.'['.$field['id'].']';?>[<?php echo $pays['name'];?>][showfield]">
  465. <option value="1" <?php if(isset($value[$pays['name']]['showfield']) && $value[$pays['name']]['showfield'] != 2) { ?>selected="selected"<?php } ?>><?php _e('Yes', 'pmpro');?></option>
  466. <option value="2" <?php if(isset($value[$pays['name']]['showfield']) && $value[$pays['name']]['showfield'] == 2) { ?>selected="selected"<?php } ?>><?php _e('No', 'pmpro');?></option>
  467. </select>
  468. </td>
  469. </tr>
  470.  
  471. <script>
  472. function pmpro_update<?php echo $pays['name'];?>TRs()
  473. {
  474. var <?php echo $pays['name'];?> = jQuery('#<?php echo $pays['name'];?>').val();
  475. if( <?php echo $pays['name'];?> == 2)
  476. {
  477. jQuery('#<?php echo $pays['name'];?>levels_tr').show();
  478. }
  479. else
  480. {
  481. jQuery('#<?php echo $pays['name'];?>levels_tr').hide();
  482. }
  483.  
  484. if( <?php echo $pays['name'];?> > 0)
  485. {
  486. jQuery('#<?php echo $pays['name'];?>_explanation').show();
  487. }
  488. else
  489. {
  490. jQuery('#<?php echo $pays['name'];?>_explanation').hide();
  491. }
  492. }
  493. pmpro_update<?php echo $pays['name'];?>TRs();
  494. </script>
  495. <?php endforeach; ?>
  496. <tr>
  497. <td scope="row" valign="top">
  498. <label><?php _e("Popular level",'kleo_framework');?></label>
  499. </td>
  500. <td>
  501. <select name="<?php echo 'kleo_'. KLEO_DOMAIN.'['.$field['id'].']';?>[kleo_membership_popular]">
  502. <option value='0'><?php _e("None", 'pmpro');?></option>
  503. <?php
  504. if ($levels) {
  505. foreach($levels as $level)
  506. {
  507. ?>
  508. <option value="<?php echo $level->id?>" <?php if($level->id == $value['kleo_membership_popular']) { ?>selected="selected"<?php } ?>><?php echo $level->name?></option>
  509. <?php
  510. }
  511. }
  512. ?>
  513. </select>
  514. </td>
  515. </tr>
  516. <tr class="bottom-border">
  517. <td scope="row" valign="top">
  518. <label for="nonmembertext"><?php _e('Order in Membership table', 'kleo_framework');?>:</label>
  519. </td>
  520. <td>
  521. <?php
  522. if ($levels) {
  523. foreach($levels as $level)
  524. {
  525. ?>
  526. <?php echo $level->name?>: <input type="text" size="2" name="<?php echo 'kleo_'. KLEO_DOMAIN.'['.$field['id'].']';?>[kleo_pmpro_levels_order][<?php echo $level->id;?>]" value="<?php if(isset($value['kleo_pmpro_levels_order'][$level->id])) echo $value['kleo_pmpro_levels_order'][$level->id]; else echo "0";?>"><br>
  527. <?php
  528. }
  529. } else { echo 'No levels added to apply sorting.'; }
  530. ?>
  531. </td>
  532. </tr>
  533. <?php
  534.  
  535. echo '</table>';
  536. }
  537.  
  538.  
  539.  
  540. /* Restrict email messages content to non paying members */
  541. if ( ! function_exists( 'kleo_pmpro_restrict_pm_email_content' ) ) {
  542. function kleo_pmpro_restrict_pm_email_content($email_content, $sender_name, $subject, $content, $message_link, $settings_link, $ud)
  543. {
  544.  
  545. $restrict_message = false;
  546. $restrict_options = kleo_memberships();
  547. $area = 'pm';
  548.  
  549. if (pmpro_getMembershipLevelForUser($ud->ID)) {
  550. $current_level_obj = pmpro_getMembershipLevelForUser($ud->ID);
  551. $current_level = $current_level_obj->ID;
  552.  
  553. //if restrict my level
  554. if ($restrict_options[$area]['type'] == 2 && isset($restrict_options[$area]['levels']) && is_array($restrict_options[$area]['levels']) && !empty($restrict_options[$area]['levels']) && in_array($current_level, $restrict_options[$area]['levels'])) {
  555. $restrict_message = true;
  556. }
  557.  
  558.  
  559. } else { /* not a member */
  560. if ($restrict_options[$area]['type'] == 2 && isset($restrict_options[$area]['not_member']) && $restrict_options[$area]['not_member'] == 1) {
  561. $restrict_message = true;
  562. }
  563. }
  564.  
  565. if ($restrict_message) {
  566.  
  567. $content = 'Your current membership does not allow private messages access.';
  568. $email_content = sprintf(__(
  569. '%1$s sent you a new message:
  570.  
  571. Subject: %2$s
  572.  
  573. "%3$s"
  574.  
  575. To view and read your messages please log in and visit: %4$s
  576.  
  577. ---------------------
  578. ', 'buddypress'), $sender_name, $subject, $content, $message_link);
  579.  
  580. // Only show the disable notifications line if the settings component is enabled
  581. if (bp_is_active('settings')) {
  582. $email_content .= sprintf(__('To disable these notifications, please log in and go to: %s', 'buddypress'), $settings_link);
  583. }
  584.  
  585. return $email_content;
  586. }
  587.  
  588. return $email_content;
  589.  
  590. }
  591. }
  592. add_filter( 'messages_notification_new_message_message', 'kleo_pmpro_restrict_pm_email_content', 11, 7 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement