Skip to:
Content
Pages
Categories
Search
Top
Bottom

Additional activity update meta


  • jakenelson09
    Participant

    @jakenelson09

    Hey there! I have been working on this for the past 3 days and cannot for the life of my figure out where I am going wrong. I am trying to add an additional input field under the activity update content field. I found a few posts about it but they are from several years ago, I am wondering if they have been outdated with updates or something. Here’s what I’ve done.

    1. Edit post-form.php with input fields

    <input name="price" id="price" type="text" />

    2. Edit global.js in the default theme folder

    /* Default POST values */
    		var object = '';
    		var item_id = jq("#whats-new-post-in").val();
    		var content = jq("textarea#whats-new").val();
    		var price = jq("input#price").val();
    		var location = jq("input#location").val();
    
    		/* added in price and location values */
    
    		/* Set object for non-profile posts */
    		if ( item_id > 0 ) {
    			object = jq("#whats-new-post-object").val();
    		}
    
    		jq.post( ajaxurl, {
    			action: 'post_update',
    			'cookie': bp_get_cookies(),
    			'_wpnonce_post_update': jq("input#_wpnonce_post_update").val(),
    			'content': content,
    			'object': object,
    			'price': price,
    			'location': location,
    			'item_id': item_id,
    			'_bp_as_nonce': jq('#_bp_as_nonce').val() || ''
    		},

    3. Add the function in bp-custom.php

    function add_trackmeta_to_activity( $content, $user_id, $activity_id ) {
    
        bp_activity_update_meta( $activity_id, 'price', $_POST['price'] );
    
    }
    
    add_action( 'bp_activity_posted_update', 'add_trackmeta_to_activity', 10, 3 );

    I am not getting anything in the database. The solution is probably staring me in the face but my mind is so burnt out, I need a fresh pair of eyes to help me out.

    Thanks for your time

    Jake

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

  • shanebp
    Moderator

    @shanebp

    Unless you are explicitly using the BP default theme, I believe you should be using this file:
    buddypress\bp-templates\bp-legacy\js\buddypress.js

    And you should be able to overload that file in your theme.


    jakenelson09
    Participant

    @jakenelson09

    Duh! Awesome, thank you for being my fresh pair of eyes! So now that I have info stored in the db, do I just need to edit the loop to get it to show up on my activity page?

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