Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello, I do not have write access to the subversion repository for this project, so I can’t directly make the changes. I’m also not familiar with the best way to submit patches for WordPress plugins, which is why I just posted it in the forum. If anyone knows a more appropriate method of tracking bugs and posted patches for this plugin, I’d appreciate the tip.

    What I posted above is a patch file http://en.wikipedia.org/wiki/Patch_(Unix) You can apply it manually by copying/pasting the lines with pluses to the mass-messaging-in-buddypress/mass-messaging.php file and removing any lines that start with minuses.

    Thread Starter ElementGreen

    (@elementgreen)

    @mrjarbenne You’re welcome. I’m glad my efforts were helpful to you.

    Cheers.

    I was having the same problem. The technical details of the issue is that the current_user_can() WordPress function is being passed role names, which does not result in the expected behavior. Below is a patch which fixes this issue:

    diff -ru mass-messaging-in-buddypress.orig/mass-messaging.php mass-messaging-in-buddypress/mass-messaging.php
    --- mass-messaging-in-buddypress.orig/mass-messaging.php	2014-08-08 23:16:24.000000000 -0700
    +++ mass-messaging-in-buddypress/mass-messaging.php	2014-08-08 23:04:46.000000000 -0700
    @@ -2,6 +2,23 @@
    
     register_activation_hook(__FILE__, 'install_massmessaging');
    
    +function check_user_role ($role, $user_id = null){
    +        $roles = array('super admin', 'administrator', 'editor', 'author', 'contributor', 'subscriber');
    +
    +	if (is_numeric($user_id))
    +		$user = get_userdata($user_id);
    +	else $user = wp_get_current_user();
    +
    +	if (empty($user))
    +		return false;
    +
    +	for ($rolendx = 0; $rolendx < count ($roles); $rolendx++)
    +		if (in_array ($roles[$rolendx], (array)$user->roles))
    +			break;
    +
    +	return $rolendx <= array_search ($role, $roles);
    +}
    +
     if(!class_exists("StormationMassMessagingPlugin")){
     	class StormationMassMessagingPlugin{
     		public function __construct(){
    @@ -224,7 +241,7 @@
     			);
     			$role = get_site_option('MassMessagingMinimumType');
     			do_action('mass_messaging_in_buddypress_before_user_can_view');
    -			if(current_user_can($role)){
    +			if(check_user_role($role)){
     				$wp_admin_bar->add_node( $wp_admin_nav );
     			}
     			do_action('mass_messaging_in_buddypress_after_user_can_view');
    @@ -235,7 +252,7 @@
    
     			$role = get_site_option('MassMessagingMinimumType');
     			do_action('mass_messaging_in_buddypress_before_user_can_view');
    -			if(current_user_can($role)){
    +			if(check_user_role($role)){
     				bp_core_new_subnav_item( array(
        					'name' => 'Mass Messaging',
        					'slug' => 'mass-messaging',
    Thread Starter ElementGreen

    (@elementgreen)

    Its a patch file – http://en.wikipedia.org/wiki/Patch_(Unix) You need to apply it to the existing sources. If you don’t have a patch program or know how to use it, you could apply the lines of text manually, since there aren’t that many changes and it is only in 2 files (buddypress-links/bp-links-templatetags.php and buddypress-links/themes/bp-links-default/index.php). Any lines that begin with the ‘-‘ symbol should be removed and lines with ‘+’ should be added (copy and paste them at the proper position in the file and remove the + symbol). You may want to make backups of the files first (although you could just re-install the plugin). Keep in mind that plugin upgrades will likely overwrite the changes, but hopefully the plugin author will fix these issues in the next release, so it wouldn’t matter then.

Viewing 4 replies - 1 through 4 (of 4 total)