Ask a specific user a question

I'm just starting out setting up a new Q&A site and I was wondering if there's a way to ask a specific user a question? The default set-up seems to be that you ask a question to everybody. Thanks :slight_smile:

  • mattbailey
    • Design Lord, Child of Thor

    Hi Mason, thanks for the reply.

    Can I give a bit more information - I forgot to mention that I'm also using Buddypress and my intention is to create a combined theme so that the users can take advantage of all social features of Buddypress, plus the Q&A features of the Q&A plugin.

    Knowing this bit of extra information do you know if it's possible, without hacking the code, to be able to use the Q&A features to ask a specific user a question?

    If I have to hack the code I assume I could set it up so that each question is tagged with the users ID number (if it isn't already) and then use this as a hook to be able to build the front-end aspects of what I want to achieve?...

  • Mason
    • DEV MAN’s Sidekick

    Hiya mattbailey,

    Apologies for the bit of delay as it was a holiday weekend here in the US.

    Knowing this bit of extra information do you know if it's possible, without hacking the code, to be able to use the Q&A features to ask a specific user a question?

    Currently there's not a way to do this. One way I can think to do it (but would still require some custom code) would be to modify the user page setup by the questions plugin or the authorbox to display a link to the display box. It'd be something like this:

    <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_private_message_link' ) ) : ?>
    	<div class="generic-button" id="send-private-message">
    		<a href="<?php bp_send_private_message_link() ?>" title="<?php _e( 'Send a private message to this user.', 'buddypress' ) ?>"><?php _e( 'Send Private Message', 'buddypress' ) ?></a>
    	</div>
    <?php endif; ?>

    Look in the qa/default-templates directory for the files there. You can copy any of them into your theme and then edit them by adding the code above. Doing so will mean you can continually update the plugin without losing your changes.

    Thanks!

  • mattbailey
    • Design Lord, Child of Thor

    Thanks Mason. Apologies for the bump, I didn't realise you had a holiday :stuck_out_tongue:

    Yes, I've set up a child theme of the default Q&A and Buddypress themes - definitely the best way to do it. I'll have a look at your sample code above and let you know how I get on.

  • Ovidiu
    • Code Wrangler

    not sure where you guys are going with this. if you are asking a specific user a question, he will be the only one able to respond, right?
    is the person asking and the one being asked the only ones able to see the question and answer?
    if yes, this is basically a pm or messaging tool.

    just trying to figure out what the purpose is :slight_smile:

  • mattbailey
    • Design Lord, Child of Thor

    I'm almost at the stage in my project where I'm going to be adding this feature.

    I think Mason's code above isn't quite what I'm wanting to achieve though - I don't want to ask a private question, I want to ask a question in the normal way, but somehow link this to a specific user so that on their profile page I can show questions that have been specifically directed at them.

    For example, someone might want to ask only me what my favourite colour is rather than asking everybody.

    I haven't thought through fully how I'm going to do this, but basically when you're on a user's profile page I will create an additional button called 'Ask [user name] a question'. I'll then tweak the form/function to record the ID of the user who is being asked the question. I'll then be able to create a new 'questions archive template' that filters out those questions asked specifically to a user if on their profile page.

    I hope all that makes sense, and I'll try and post my code when I've done it although it's going to take quite a bit of customising...

  • mattbailey
    • Design Lord, Child of Thor

    @Ovidiu Yes, kind of like using hashtags. In a nutshell I need to link a question with a certain user, so the plugin not only records who asked the question, but who it was asked to. Then when on that user's profile you will be able to see those questions that have been asked to them. Simple right?... :stuck_out_tongue:

    However, I still want it to be open so that any user can respond with answers, which can be voted on in the normal way.

    All this plus I'm integrating it with Buddypress! It's coming together nicely and will be pretty cool when done (I hope)!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.