coopersita (@coopersita)

Forum Replies Created

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

  • coopersita
    Participant

    @coopersita

    I haven’t made much progress. I tried adding a rewrite rule and changing from ‘users’ from ‘members’ to avoid rules clashing:

    function bbp_custom_author_rewrite(){
        add_rewrite_rule(
            "^forums/members/([^/]*)$",
            'index.php?bbp_user=$matches[1]',
            "top"
        );
    }
    add_action( 'init', 'bbp_custom_author_rewrite', 10);

    But I think I’m missing the part where the template uses the query var to load the correct content because I keep getting 404 errors.


    coopersita
    Participant

    @coopersita

    Thanks, but unfortunately, the registration is being done via another plugin (we do bulk registration for courses using a CSV file, and the plugin uses the email to create the logins).

    I think that if I can add a rewrite rule so the user id also redirects to the profile page, that would be enough.

    I’ll post here if I find a solution.


    coopersita
    Participant

    @coopersita

    Thanks. I actually rolled my own solution with the post anonymously checkbox. I’m not too concerned that people will post with their names by mistake and be too upset. Here’s the code I’m using in case someone else is looking. For this setup to work, you just need to create an “anonymous’ user, so all topics that are flagged will be attributed to the user and the original user id is saved as a meta field so the system isn’t abused (so mostly anonymous, but not completely):

    //Anonymous publishing in forums
             //add fields to form (checkbox)
             add_action ( 'bbp_theme_after_topic_form_content','bbp_extra_fields');
             //save fields and change author
             add_action ( 'save_post_topic', 'bbp_save_extra_fields', 10, 2);
             //display original author for admins above topic
             add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields');
    
        function bbp_extra_fields() {
           $value = get_post_meta( bbp_get_topic_id(), 'is_anonymous', true);
            echo "<input type='checkbox' name='is_anonymous' id='is_anonymous' value='yes' ".checked('yes', $value)."> &nbsp;";
            echo '<label for="is_anonymous">Post this topic anonymously</label>';
            echo '<p><strong>Note:</strong> By checking this box, your identity will be hidden from other participants, but not from moderators nor admins. </p>';
        }
        
        function bbp_save_extra_fields( $post_id, $post) {
            if(isset($_POST['is_anonymous']) && $_POST['is_anonymous'] === 'yes') {
                $anon_ID = 1; // Id of dedicated anonymous user
                // update post if it's not anonymous already
                if($post->post_author != $anon_ID) {
                    update_post_meta($post_id, 'is_anonymous', $post->post_author);
                    wp_update_post( array(
                        'ID' => $post_id,
                        'post_author' => $anon_ID 
                    ) );
                }
            }
        }
        
        function bbp_show_extra_fields() {
            if(current_user_can('delete_others_topics')) {
              $topic_id = bbp_get_topic_id();
              $anon_author = get_post_meta( $topic_id, 'is_anonymous', true);
              if($anon_author) {
                    $user = get_user_by('ID', intval($anon_author));
                    if($user) {
                        echo "Original Author: <a href='".site_url()."/forums/users/".$user->user_login."'>".$user->display_name."</a><br>";
                    }
                }
            }
        }

    The code is only for posting topics. I’m not sure if for my use case replies would also need to be anonymous. We mostly want people to be able to ask questions openly without fear of being recognized by their peers (some users know each other).


    coopersita
    Participant

    @coopersita

    I found the issue. The bio we have is a custom field so the bio is now a WYSIWYG field instead.


    coopersita
    Participant

    @coopersita

    Strange. It shows here, but not on my site.


    coopersita
    Participant

    @coopersita

    Same question here.

    I tried the “Avatar Upload” plugin, but it doesn’t work. When I click in the “Avatar” link in the profile, it just sends me to the home page.

    Thanks


    coopersita
    Participant

    @coopersita

    Same question here.

    I tried the “Avatar Upload” plugin, but it doesn’t work. When I click in the “Avatar” link in the profile, it just sends me to the home page.

    Thanks


    coopersita
    Participant

    @coopersita

    Never mind. Stick to topic vs Stick to front…


    coopersita
    Participant

    @coopersita

    Never mind. Stick to topic vs Stick to front…

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