Palagrin (@palagrin)

Forum Replies Created

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

  • Palagrin
    Participant

    @palagrin

    Thanks. Do you know how I can loop through all users in a function? I can’t seem to work it out.


    Palagrin
    Participant

    @palagrin

    Potentially something like this, although it isn’t working as far as I can tell:

    function bbp_change_user_role_login($user) {
    
    $user_id = get_current_user_id($user);
    $current_user_role = bbp_get_user_role($user_id);
    $new_role_forum_role="bbp_moderator";
    $user_post_count = bbp_get_user_post_count( $user_id );
    
    if (($current_user_role = "bbp_participant") and ($user_post_count > 20)) {
    bbp_set_user_role( $user_id, $new_forum_role );
    }
    
    }
    add_action('wp_login', 'bbp_change_user_role_login');
    

    Palagrin
    Participant

    @palagrin

    This seems to be a good starting point.

    Ok, so whilst there doesn’t seem to be a function I can filter that based on the post count, I could potentially run a function that changes someone’s role based on their post count every time they login? That would keep database queries to a minimum and still ensure the update happens fairly regularly.

    Any idea what filter or action I can use when a user logs in? Can I just use the wp_login action?


    Palagrin
    Participant

    @palagrin

    I’ve just noticed that BBP also generates a dedicated search page. Will have a dig and see how that’s done.


    Palagrin
    Participant

    @palagrin

    the topic and reply forms are at the bottom of the forum and topic pages, so there is no need to visit a separate page.

    Well, yes, but it would be neat to have the option.

    I already link to the bottom of the page form via the html anchor – I’ve coded that into my theme – but I’m trying to have these forms on separate pages entirely, to make the whole thing a bit neater.


    Palagrin
    Participant

    @palagrin

    Interestingly, when you click ‘edit’ on a reply it takes you to a new page where you can edit the reply. So somehow that should be possible to generate a NEW reply.


    Palagrin
    Participant

    @palagrin

    That’s exactly what I want – I WANT it to use the template files!

    Whilst I can use the short code bbp-new-reply for example, it needs a topic ID to work. I simply don’t understand why BBP core doesn’t generate these pages programmatically – it makes absolutely no sense to me. You would think that would be basic functionality for a forum plugin!


    Palagrin
    Participant

    @palagrin

    Surely it can be done with a function? The plug-in must already be generating pages for the index, user profiles etc. Could creating a function create a page dynamically?

    Obviously it is “just” 5 pages but for larger forums it seems a little absurd to have to create identical “new topic” pages for each one!


    Palagrin
    Participant

    @palagrin

    To add to my answer, for example BBP already appears to do this with users – ie. it creates pages based on site.com/forums/users/username


    Palagrin
    Participant

    @palagrin

    But that’s using the shortcodes and creating dedicated pages in WP right?

    I want BBP to automatically generate these pages, eg. https://mywebsite.blog/forums/login

    Pages required would be:
    – login
    – register
    – password reset
    – new topic
    – new reply

    My understanding of the shortcode is that if I wanted a new topic page, I would either have to have a generic one for the whole board or I would have to create individual ones for each forum based on the forum ID.

    The solution I’m looking for is for BBP to dynamically generate them as required. Is that possible?

    It seems odd to me that BBP doesn’t already do this.

    EDIT: would something along these lines work? https://stackoverflow.com/questions/32314278/how-to-create-a-new-wordpress-page-programmatically


    Palagrin
    Participant

    @palagrin

    Basically, instead of having the create topic / topic reply form on the same page as the thread I want to create a button that links to a secondary page. I know this is possible with shortcodes, but is there a way of doing this without shortcodes? So that BBP auto-generates the page itself?

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