Skip to:
Content
Pages
Categories
Search
Top
Bottom

Choose categories or tags for activities


  • mrjcgoodwin
    Participant

    @mrjcgoodwin

    Hi, we’re thinking of deploying Buddypress for a new community project. I’m trying to find out if there is a way of utilising categories or tags for activity posts.

    Ideally we want users to choose from a few categories when posting their activity, i.e. ‘chit-chat’ or ‘announcement’ or ‘event’ etc. Is this possible with BP?

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

  • Henry Wright
    Moderator

    @henrywright

    BuddyPress activity items aren’t WordPress posts so as far as I know you can’t associate categories or tags with them. However, activity items do have associated meta.

    Take a look at these functions which will be useful to you:

    bp_activity_add_meta()
    bp_activity_update_meta()
    bp_activity_get_meta()
    bp_activity_delete_meta()

    mrjcgoodwin
    Participant

    @mrjcgoodwin

    Thanks Henry will check this out. It’s not necessarily important that the meta info is using the same structure as the regular WP ones, just that we can segregate the the activity types if possible.

    Would you suggest we would be able to mod the activity form then to achieve this, or are we better off doing this another way. I’m new to BP, but surprised this isn’t a baked in function.


    Henry Wright
    Moderator

    @henrywright

    Meta would allow you to segregate activity item types. You could add to meta after a new activity item is posted. The hook for that is bp_activity_add.

    Hope this helps.


    mrjcgoodwin
    Participant

    @mrjcgoodwin

    Thanks for your help the other day, I’ve almost got this all sorted now, but coming unstuck on the last bit of displaying my new meta info on the front end, hoping you can spot my error in the below!

    I’m modding the entry.php template to display my new meta data:

    If I use

    
    $actID = bp_activity_id();
    echo bp_activity_get_meta( $actID,'Activity Title' );
    

    it wrongly returns the ID of the activity instead of the meta data for the key ‘Activity Title’.

    If I hard code the ID number in it works, e.g.:

    
    //$actID = bp_activity_id();
    echo bp_activity_get_meta( 40,'Activity Title' );
    

    I also know that bp_activity_id() is getting the correct ID numbers as if I simply echo out its value it correctly appends a different ID to each activity output by the template, but I cannot combine the two.

    I’ve also tried ensuring the ID number is an integer before using it in the get_meta function. Any ideas? I’m puzzled!!

    (Note I’ve changed my goal slightly, I’m now just displaying a custom title field for an activity in case you were wondering.)


    mrjcgoodwin
    Participant

    @mrjcgoodwin

    Oops – obvious mistake – got to use bp_get_activity_id(); instead.


    Henry Wright
    Moderator

    @henrywright

    Can you see what bp_activity_id() is returning by using var_dump() on the $actID variable?


    mrjcgoodwin
    Participant

    @mrjcgoodwin

    Thanks for the reply – I already fixed it in the end as per post above – I was using bp_activity_id() by mistake instead of bp_get_activity_id() which fixed it :-).

    Thanks for all your pointers – first time using BP so the help has gone a long way!


    Henry Wright
    Moderator

    @henrywright

    Great to hear! A typo in the function name is always a hard one to debug unless the function doesn’t exist and you get a PHP error.


    mrjcgoodwin
    Participant

    @mrjcgoodwin

    There’s one last thing you might be able to provide me with a bit of a pointer on….

    I’m trying to make my new field compulsory, but cannot get my head round where/how BP is handling the validation for the default field. Any idea how I can implement this? – ideally in a non-destructive way.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar