• Resolved ijogold

    (@ijogold)


    Hello, please tell me how to remove an individual permission?

    i do the following for adding individual permission and it works fine

    $args = array(
      'operation'       => 'read',
      'mod_type'        => 'additional',
      'for_item_source' => 'post',
      'for_item_type'   => 'post',
      'via_item_source' => 'post',
      'item_id'         => $post_id,
    );
    $agents = array();
    $agents['item'][ $prorabid ] = true;
    ppc_assign_exceptions( $agents, 'user', $args );
    
    

    But how can I remove this permission?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter ijogold

    (@ijogold)

    Can you answer me?

    Plugin Support Riza Maulana Ardiyanto

    (@rizaardiyanto)

    Hi @ijogold

    Thank you for using PublishPress. We do our best to answer all questions, but more complicated coding questions may take longer to answer than regular questions. Please be patient until one of our developer have a chance to review your question

    Thread Starter ijogold

    (@ijogold)

    Hello, thank you, looking forward to

    Plugin Author Kevin Behrens

    (@kevinb)

    @ijogold You can use the same function call, but changing the $agents value from true to nullstring:

    $agents['item'][ $prorabid ] = '';
    ppc_assign_exceptions( $agents, 'user', $args );

    Thread Starter ijogold

    (@ijogold)

    @kevinb did you check it? Because it’s the wrong answer and it doesn’t work! “=”

    I’m very sad! So much wasted time =(

    • This reply was modified 1 year, 8 months ago by ijogold.
    Thread Starter ijogold

    (@ijogold)

    @kevinb Look at my screenshot https://prnt.sc/aoZuGMBtfK7z
    I want to change the read post permissions for one of the users

    As a result, I want – so that it turns out https://prnt.sc/lMfz9KEfe1md

    But your code in the answer doesn’t!

    • This reply was modified 1 year, 8 months ago by ijogold.
    • This reply was modified 1 year, 8 months ago by ijogold.
    Plugin Author Kevin Behrens

    (@kevinb)

    @ijogold My answer was based on the plugin’s internal usage of that function. I’ll find some time later today to try a test case and look into what might be going wrong.

    Thread Starter ijogold

    (@ijogold)

    @kevinb Thank you! I will look forward to it!

    • This reply was modified 1 year, 8 months ago by ijogold.
    Plugin Author Kevin Behrens

    (@kevinb)

    @ijogold I confirmed that the code snippet does work. After using the Edit User Permission screen to assign a Specific Permission with those parameters to a user, I was able to remove it using your (modified) code.

    Are you sure the parameters are all correct for the permission you’re trying to delete? You set $post_id for the Post and $prorabid for the User ID ahead of these lines?

    Are you sure the permission you’re trying to delete is:

    • Assigned directly to the user (not to a group or role they are a member of)?
    • For post type “Post” ?
    • For Operation “Read” ?
    • For Adjustment “Enable” ?

    Another possible problem is executing the code too early. Try calling it within a function that is hooked to the “init” action. If you’re trying to execute it immediately after a plugin or theme file loads, that may be the problem.

    Thread Starter ijogold

    (@ijogold)

    @kevinb

    hello, yes, I’m sure that the necessary data is transferred to $post_id and $prorabid…

    my code for adding rights works great – but removing these rights does not work!

    The function works for me at the time of publishing or editing a post

    i tried like this:

    $agents['item'][ $prorabid ] = ''; 
    ppc_assign_exceptions( $agents, 'user', $args );

    and

    $agents['item'][ $prorabid ] = 'false'; 
    ppc_assign_exceptions( $agents, 'user', $args );

    both ways don’t work =(

    Do I understand correctly that you first added read permissions to the user using my code, and then removed them using your code that you wrote to me above?

    please write me the full code you used to remove the user’s rights to read the post ?

    • This reply was modified 1 year, 8 months ago by ijogold.
    • This reply was modified 1 year, 8 months ago by ijogold.
    Thread Starter ijogold

    (@ijogold)

    @kevinb

    my code to remove exceptions for a user that doesn’t work

    $argsdelite = array(
    'operation'       => 'read',
    'mod_type'        => 'additional',
    'for_item_source' => 'post',
    'for_item_type'   => 'post',
    'via_item_source' => 'post',
    'item_id'         => $post_id,
    );
    $agentsdelite = array();
    $agentsdelite['item'][ $prorabdeliteid ] = '';
    ppc_assign_exceptions( $agentsdelite, 'user', $argsdelite );
    • This reply was modified 1 year, 8 months ago by ijogold.
    • This reply was modified 1 year, 8 months ago by ijogold.
    • This reply was modified 1 year, 8 months ago by ijogold.
    • This reply was modified 1 year, 8 months ago by ijogold.
    Thread Starter ijogold

    (@ijogold)

    @kevinb

    Indeed, it works!
    I found a bug in adding and removing user rights at the same time! Thanks a lot!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to remove an individual permission?’ is closed to new replies.