Block Users v1.0.0

Release Notes:

Initial release

  • so if the blocked user can see the activity events from the blocker, are they able to comment on them there?

  • Hello, this plugin is very necessary. But in Elgg 2.3 error occurs. Is there an update forecast?
     
    
     
  • Erro in Elgg 2.3.2

    Argument 1 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, null given, called in /home/familia1/public_html/mod/block_users/start.php on line 183

    TypeError Object
    (
    [message:protected] => Argument 1 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, null given, called in /home/familia1/public_html/mod/block_users/start.php on line 183
    [string:Error:private] => TypeError: Argument 1 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, null given, called in /home/familia1/public_html/mod/block_users/start.php on line 183 and defined in /home/familia1/public_html/mod/block_users/lib/functions.php:49
    Stack trace:
    #0 /home/familia1/public_html/mod/block_users/start.php(183): MFP\BlockUsers\is_blocked(NULL, Object(ElggUser))
    #1 [internal function]: MFP\BlockUsers\check_page_owner('pagesetup', 'system', NULL)
    #2 

  • // viewing user is blocked by content owner.
    if (is_blocked($viewing_user, $page_owner)) {  LINE 183
    forward('block_users/blocked_content');
    }
  • This error happens when the user is locked. Should show the blocked page then this error happens.
     
    
     
  • Can someone help me with this problem? Any idea? Important network user may be able to block another user. Does anyone have any type and block on the network that can help?
  • Hi @Vagsiarom, The plugin worked fine with Elgg 2.3.3. I blocked a user and then I tried to view the user profile and it showed me the blocked page with the message "You are trying to view content from or perform an action on a user that you have blocked. To see this user's content, you must first unblock the user."

    Do let me know how did you got the error? What action were you performing? A little more details would help.

  • Thank you Rohita. My Elgg is version 2.3.2. The problem occurs when you block the user. The error I posted here appears. This error is in the blocked user profile and only in it. And only appears to who blocked. If you can help me, thank you.
     
    
     
  • Rohita updated my elgg for 2.3.3 and even then the error persists. Can anyone help?
     
    
     
  • Only looked at the code and not tried myself. But I think it might help to change line 172 of start.php a little bit. The modified code would be

    function check_page_owner($event, $type, $return) {
        $page_owner = elgg_get_page_owner_entity();
        if ((!$page_owner) || (!$page_owner instanceof \ElggUser)) {
            return null;
        }

    checking also if $page_owner is a user entity (as this might not be always the case - for example not in groups).

  • Iionly, you're awesome. Only yourself to solve this. thank you so much. Line 172 of start.php has "if (! $ Page_owner)" change to "if (! $ Page_owner instanceof \ ElggUser)". Probema solved. Thank you master iionly.
     
    
     
  • Iionly! Now another problem with user lock plugin. When you are going to send a message to a new name, see the error below:

     

    Argument 2 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, boolean given, called in /home/familia1/public_html/mod/block_users/start.php on line 248

    TypeError Object
    (
    [message:protected] => Argument 2 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, boolean given, called in /home/familia1/public_html/mod/block_users/start.php on line 248
    [string:Error:private] => TypeError: Argument 2 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, boolean given, called in /home/familia1/public_html/mod/block_users/start.php on line 248 and defined in /home/familia1/public_html/mod/block_users/lib/functions.php:49
    Stack trace:
    #0 /home/familia1/public_html/mod/block_users/start.php(248): MFP\BlockUsers\is_blocked(Object(ElggUser), false)
    #1 [internal function]: MFP\BlockUsers\messages_send_action('action', 'messages/send', true, NULL)
    #2 /home/familia1/public_html/vendor/elgg/elgg/engine/classes/Elgg/PluginHooksService.php(52): call_user_func_array('MFP\\BlockUsers\\...', Array)
    #3 /home/familia1/public_html/vendor/elgg/elgg/engine/classes/Elgg/ActionsService.php(166): Elgg\PluginHooksService->trigger('action', 'messages/send', NULL, true)
    #4 /home/familia1/public_html/vendor/elgg/elgg/engine/lib/actions.php(22): Elgg\ActionsService->execute('messages/send')
    #5 [internal function]: _elgg_action_handler(Array, 'action')
    #6 /home/familia1/public_html/vendor/elgg/elgg/engine/classes/Elgg/Router.php(100): call_user_func('_elgg_action_ha...', Array, 'action')
    #7 /home/familia1/public_html/vendor/elgg/elgg/engine/classes/Elgg/Application.php(436): Elgg\Router->route(Object(Elgg\Http\Request))
    #8 

  • Can someone help me????
     
    
     
  • Help you scream? Sure!

    Can someone help me????

  • I do not think you understand me because the translator may not turn my ideas in a way that can be understood. Anyway, thanks for showing up here. There is already a history with every event with plugin block user. If you can not help please do not play or get in the way. I still need help. Iionly helped in the beginning when I changed Line 172 of start.php has "if (! $ Page_owner)" change to "if (! $ Page_owner instanceof \ ElggUser)". But now I have discovered that there is an error on line 248 when I send a message.
     
    
     
  • Now another problem with user lock plugin. When you are going to send a message to a new name, see the error below:
    function messages_send_action($hook, $type, $return, $params) {
    $user = get_user_by_username(get_input('recipient_username'));
    if (is_blocked(elgg_get_logged_in_user_entity(), $user)) { HERE ERROR
    elgg_make_sticky_form('messages');
    register_error(elgg_echo('block_users:blocked_content_notice'));
    return false;
    }
    }
    --------------------------------------------

    Argument 2 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, boolean given, called in /home/familia1/public_html/mod/block_users/start.php on line 248

    TypeError Object
    (
    [message:protected] => Argument 2 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, boolean given, called in /home/familia1/public_html/mod/block_users/start.php on line 248
    [string:Error:private] => TypeError: Argument 2 passed to MFP\BlockUsers\is_blocked() must be an instance of ElggUser, boolean given, called in /home/familia1/public_html/mod/block_users/start.php on line 248 and defined in /home/familia1/public_html/mod/block_users/lib/functions.php:49
    Stack trace:
    #0 /home/familia1/public_html/mod/block_users/start.php(248): MFP\BlockUsers\is_blocked(Object(ElggUser), false)
    #1 [internal function]: MFP\BlockUsers\messages_send_action('action', 'messages/send', true, NULL)
    #2 /home/familia1/public_html/vendor/elgg/elgg/engine/classes/Elgg/PluginHooksService.php(52): call_user_func_array('MFP\\BlockUsers\\...', Array)
    #3 /home/familia1/public_html/vendor/elgg/elgg/engine/classes/Elgg/ActionsService.php(166): Elgg\PluginHooksService->trigger('action', 'messages/send', NULL, true)
    #4 /home/familia1/public_html/vendor/elgg/elgg/engine/lib/actions.php(22): Elgg\ActionsService->execute('messages/send')
    #5 [internal function]: _elgg_action_handler(Array, 'action')
    #6 /home/familia1/public_html/vendor/elgg/elgg/engine/classes/Elgg/Router.php(100): call_user_func('_elgg_action_ha...', Array, 'action')
    #7 /home/familia1/public_html/vendor/elgg/elgg/engine/classes/Elgg/Application.php(436): Elgg\Router->route(Object(Elgg\Http\Request))
    #8 

  • $user = get_user_by_username(get_input('recipient_username'));

    I think in later versions of the messaging plugin the input changed, you'll need to see what is passed and correct accordingly.  There is no get_input('recipient_username') so $user ends up being null which triggers the error.

  • I think it should work with modifying the messages_send_action() function in start.php to

    function messages_send_action($hook, $type, $return, $params) {
        $recipients = (array) get_input('recipients');
    
        if (empty($recipients)) {
            register_error(elgg_echo("messages:user:blank"));
            forward("messages/compose");
        }
    
        $recipient = (int) elgg_extract(0, $recipients);
        $user = get_user($recipient);
    
        if (is_blocked(elgg_get_logged_in_user_entity(), $user)) {
            elgg_make_sticky_form('messages');
            register_error(elgg_echo('block_users:blocked_content_notice'));
            return false;
        }
    }

    But as I don't use this plugin I haven't tested the code.

  • Master Iionly once again I thank you very much. Problem solved. I wanted to have this knowledge but I'm working hard for it. I would update a lot of plugins that are interesting but have been forgotten. Thank you!
     
    
     

Arck Interactive

You imagine. We create. We develop custom social networks, content management systems and other rich internet applications. We help entrepreneurs and creative agencies breathe life into their visions. Let's start a conversation!

Project Info

Stats

  • Category: User admin
  • License: GNU General Public License (GPL) version 2
  • Updated: 2015-10-10
  • Downloads: 508
  • Recommendations: 2

Other Projects

View Arck Interactive's plugins