Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_activity_add() not working in theme ajax hooks

  • Avatar of rmughal
    rmughal
    Participant

    @rmughal

    I am trying to add an activity for the current user through a function hooked to wp_ajax

    add_action(“wp_ajax_add_pair”, “some_function”);

    function some_function(){
    $args = array(‘action’=>’action string’);
    bp_activity_add($args);
    }

    some_function is called through ajax but I get bp_activity_add does not exist. This makes me think that BP hasnt loaded yet, but var_dump($bp) shows the variable is set. So need help to record activity for a user through ajax

Viewing 1 replies (of 1 total)
  • Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    try:

    function bp_some_function() {
    
        add_action( “wp_ajax_add_pair”, “some_function” );
    
    }
    add_action( 'bp_include','bp_some_function' );
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.