norcom41 (@norcom41)

Forum Replies Created

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

  • norcom41
    Participant

    @norcom41

    I tried this in a plugin recently but I can’t tell what it does:

    add_action(‘wp_loaded’,’modify_participant’);

    function ‘modify_participant'()
    {
    add_filter(‘mod_participant’, ‘upd_participant’);
    }

    function upd_participant($caps,$role)
    {
    $role = bbp_get_participant_role();
    $caps = modify_capabilities($role);
    }

    function modify_capabilities($caps)
    {
    $caps = array(

    // Topic caps
    ‘publish_topics’ => false,
    ‘edit_topics’ => false,
    ‘edit_others_topics’ => false,
    ‘delete_topics’ => false,
    // Primary caps
    ‘spectate’ => true,
    ‘participate’ => true,
    ‘moderate’ => false,
    ‘throttle’ => false,
    ‘view_trash’ => false,

    // Forum caps
    ‘publish_forums’ => false,
    ‘edit_forums’ => false,
    ‘edit_others_forums’ => false,
    ‘delete_forums’ => false,
    ‘delete_others_forums’ => false,
    ‘read_private_forums’ => false,
    ‘read_hidden_forums’ => false,

    ‘delete_others_topics’ => false,
    ‘read_private_topics’ => false,

    // Reply caps
    ‘publish_replies’ => true,
    ‘edit_replies’ => true,
    ‘edit_others_replies’ => false,
    ‘delete_replies’ => false,
    ‘delete_others_replies’ => false,
    ‘read_private_replies’ => false,

    // Topic tag caps
    ‘manage_topic_tags’ => false,
    ‘edit_topic_tags’ => false,
    ‘delete_topic_tags’ => false,
    ‘assign_topic_tags’ => false
    );
    return $caps;
    }


    norcom41
    Participant

    @norcom41

    Some research (paraphrased) is: “Roles are stored in the database so modifying capabilities shouldn’t be done on every page load. They are stored as a serialized array in wp-config.php under the wp_user_roles option. Because adding capabilities to a role is a permanent change, you should only do this when a plugin is activated. I tried to change a T/F value but it failed perhaps because WP doesn’t permit updates that way. However if I delete a role and then later change a capability it succeeds (end paraphrase).”
    So using a plugin to update participant capabilities each time temporarily appears to be discouraged as opposed to the admin making permanent updates using the file manager from the dashboard. However, you’d think with the current level of sophistication and a logical need for it a simple plugin for just that one purpose would exist somewhere.


    norcom41
    Participant

    @norcom41

    I suppose add_filter(‘mod_’,’upd_($role,$caps)’) should have this for arguments even though they’re for the return values. bbp_get_participant_role probably provides the elements for all the capabilities, but if only some are modified in the array, the others could be lost during the return if not also repeated. In my test the init statements are displayed on the screen as if they are errors. Then when the user choses a subforum it prompts for a login to add a topic. This opens up another area to suppress that request itself. That’s why programmers get plugins because you have to be an expert to know how to do all this. If you want to know the basics you have to go back to school.


    norcom41
    Participant

    @norcom41

    I considered how tricky it might be to customize how forum functioning takes place. I read that you can create new roles that redefine what capabilities users have even to do things differently. But roles don’t seem to be stored in wp_users. However I did read that definitions are in the wp_users_roles option of the wp_options table. There are forum roles which would have to be coded differently using hooks, filters and actions. It’s always best to keep things simple. It sounds so complex that maybe it would be better to tell students not to create new topics or else the administrator would just have to delete them.


    norcom41
    Participant

    @norcom41

    When you download a plugin apparently it doesn’t automatically install at that time. But it seems that certain documentation is available to explain things if the provider has given it depending how helpful it is. So it just sits there until it’s activated. However, once it’s installed is it easy to uninstall if there’s a problem? I remember one download which I installed for something else that became that way and it was a chore finding what was stored in many different places. So apparently this one is different than the above http://www.buddydev.com/etc plugin?


    norcom41
    Participant

    @norcom41

    In Oct/2022 I found http://www.buddydev.com/restrict-user-from-creating-topic-on-certain-bbpress-forums. I printed out some code to look at it and some comments about it. I put the info in the learn how to use short-code in my notebook to study when I had time. It seemed complicated and only for advanced developers and I haven’t used short-codes as yet. But most of the developer reviews in that place seemed positive. The few negatives had to do with the code being beyond their expertise. I checked the reference in your reply and it seemed to fall into the category of an advanced approach. But I was just wondering if someone by now had figured out an easier way to solve my question because it seems to be a logical requirement to have a solution for. However, in my searching one person said “who would want to do something like that when that’s not what it’s meant for” I’ll have to study it all so I can be more comfortable trying it.

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