Ask a Question categories

I would like to wrap the categories in the Select a category drop down list box in a decision statement so that a visitor can only see the category that he has access to rather than all the categories.

Where exactly will I find the code for this drop down list box?

I have already made appropriate categories and protected them with s2member.

Thanks

  • aristath
    • Recruit

    Hello again @11 Plus for Parents!

    Usually categories dropdown are generated using this function: wp_dropdown_categories

    I haven't tried this so I can't really guarantee its success, but you could copy the function from WordPress core to your theme's functions.php (the function is located here), rename it to something like custom_wp_dropdown_categories to avoid duplicate function conflicts and then edit line 608 of the qa/core/template-tags.php file from
    $out .= wp_dropdown_categories( array(
    to
    $out .= custom_wp_dropdown_categories( array(

    I hope that helps point you to the right direction...

    Cheers!
    Ari.

  • 11 Plus for Parents
    • The Incredible Code Injector

    @aristath

    Thanks for checking in.

    This one got bumped down the list a bit because it is not something that is obvious to the visitor and a couple other things arose that presented an eye sore or just plain didn't work right and had to be fixed.

    It can be slow going at times since I have no previous knowledge of HTML, CSS, PHP etc. and have to learn/figure out everything as I go along.

    Plus this one will require concentration, you know, get the kids out of the house kind of time :slight_smile:

    Will check back in a day or two.

    Thanks again

  • aristath
    • Recruit

    Is it feasible to cause all question and answer activity to take place within BuddyPress?

    You mean integrate q&a questions and answers to be displayed in the user's activity feed?

    Is there a way to link groups to Q&A categories?

    Not to my knowledge (but then again I haven't tried it before...)

    Cheers,
    Ari.

  • 11 Plus for Parents
    • The Incredible Code Injector

    @aristath

    Here is what I need to do and hopefully you can help me with the how:

    I have Category IDs and I have s2memeber roles.

    I need to test for the s2member role of the user and populate the categories array only with the appropriate assigned categories and then output as in line 608 of the qa/core/template-tags.php as you said.

    I do not need to trouble the statements at line 608. I just need to make sure that it is appropriately populated before the output statement.

    What I need to know is where and how to populate the category array.

    I've been searching the code but can't seem to find it.

    Thanks.

  • 11 Plus for Parents
    • The Incredible Code Injector

    There was more to the info that you gave me than I first realized. I went to "like it" and realized that I had already liked it and even though I now like it even more I can't give two likes :slight_smile:

    I can exclude categories by including a statement such as the one given below in the code at line 608 of the qa/core/template-tags.php that you drew to my attention.

    'exclude' => '24, 25',

    Where 24 and 25 are two category IDs.

    I will now work out the conditions to exclude on a level by level basis.

    Thanks a million. Your input has been and continues to be invaluable.

    P.S. Do you think we can go for putting the Q&A info in the group activity stream?

  • 11 Plus for Parents
    • The Incredible Code Injector

    Victory.

    Head on over and see what your cooperation accomplished: http://www.onlinelearningexchangebase.com

    There are six categories in all. You should only be able to see two; Math and English Q&A when you are logged in and should only be able to view questions if you are not.

    While you're there @Brian told me how to put a space between the header and the question menu, but I still need a line across the top of the Q&A menu bar.

    My efforts produced a line straight across the page which I since removed.

    Do you know how to get a line just across the top of the Q&A menu?

    Thanks

  • aristath
    • Recruit

    @11 Plus for Parents

    There was more to the info that you gave me than I first realized. I went to "like it" and realized that I had already liked it and even though I now like it even more I can't give two likes :slight_smile:
    Thank you!

    Victory

    Wow, once you start going there really is no stopping you... :stuck_out_tongue: I just saw all your posts, you've been hard at work here! Congrats!!

    Do you know how to get a line just across the top of the Q&A menu?

    I'm not sure I fully understand, but if I do thn you're looking at something like this:

    #qa-menu {
      border-top: 1px solid #666;
      border-bottom: 1px solid #666;
      padding-top: 5px;
      padding-bottom: 5px;
    }

    the border-top line adds a line on top of the menu
    the border-bottom line adds a line on the bottom of the menu
    the padding-top line adds a 5px padding between the menu and the line on the top
    the padding-bottom line adds a 5px padding between the menu and the line on the bottom.

    You can adjust the color by changing the #666 value I 've entered in my example. :slight_smile:

    I hope that helps!

    Cheers,
    Ari.

  • 11 Plus for Parents
    • The Incredible Code Injector

    The code:

    First find the current user role...

    function get_user_role($id=null)
       {
         global $current_user;
         if(!$id) $id = $current_user->ID;
         if ( is_user_logged_in() )
         {
           $user = new WP_User( $id );
    
         if ( !empty( $user->roles ) && is_array( $user->roles ) )
           {
            foreach ( $user->roles as $role )
            return $role;
           }
         }
       }

    Next decide on the condition and wrap it around the code at line 608 of the qa/core/template-tags.php e.g. (I've also included an else to serve as a default)

    if (get_user_role() == 's2member_level1'  )
    
    {
        $out .= wp_dropdown_categories( array(
    	    'orderby' => 'name',
    	    'order' => 'ASC',
    	    'taxonomy' => 'question_category',
    	    'selected' => $question->cat,
    	    'hide_empty' => false,
    	    'hierarchical' => true,
    	    'name' => 'question_cat',
    	    'class' => '',
    	    'exclude' => '24, 25',
    	    'show_option_none' => __( 'Select category...', QA_TEXTDOMAIN ), 'echo'	=> 0
    	    ) );
    
    }
    else
         {		
    
         $out .= wp_dropdown_categories( array(
    	     'orderby' => 'name',
    	     'order' => 'ASC',
    	     'taxonomy' => 'question_category',
    	     'selected' => $question->cat,
    	     'hide_empty' => false,
    	     'hierarchical' => true,
    	     'name' => 'question_cat',
    	     'class' => '',
    	     'show_option_none' => __( 'Select category...', QA_TEXTDOMAIN ), 'echo'	=> 0
    	     ) );
    
    }

    Right now all of this code is in the template-tags.php file, but I am hoping that someone will volunteer to help me get it into the functions.php file if that is possible.

    Thanks @aristath :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.