Cant seem to trigger the bp_activity_set_action after form submission
-
Hello,
I am trying to add a custom activity action and add it to the database after a form is submitted. The activity does not show on the activity stream and it is not added on the database.
I can’t figure out why. Here is my code below first I use the bp_activity_set_action and bp_activity_add inside the nen_register_activity_actions action as suggested on the documentation, I define the component id-s and callback but can’t figure out why the the activity is not registred and not added on the database.
Thank you to everyone for the help
add_action("gform_after_submission_79", "nen_update_date_time_treaty", 10, 2); function nen_update_date_time_treaty($entry, $form) { $user_id = get_current_user_id(); $treaty_date = date('Y/m/d'); $status = rgar( $entry, '4.1' ); // var_dump($status); if ($status == '1') { //global $bp; //get the current user link with First Name and last name // $buddypress_link = bp_core_get_userlink( bp_loggedin_user_id(), $no_anchor = false, $just_link = false ); // //post buddypress activity // bp_activity_post_update(array('content' =>"$buddypress_link has ratified the <a href='/ratify-new-earth-treaty' target='_blank' class='fancybox'>New Earth Treaty</a> ", 'user_id' => bp_loggedin_user_id())); function nen_register_activity_actions() { global $bp, $wp_query; $bp = buddypress(); /* arguments are : - 'component_id', 'component_action_type' to use in {$wpdb->prefix}bp_activity database - and 'caption' to display in the select boxes */ bp_activity_set_action( $bp->activity->id, 'nen_treaty_ratified', __( 'Ratified new earth treaty', 'buddypress' ), 'bp_activities_format_activity_action_left_group', __( 'Members Ratified', 'buddypress' ), array( 'activity', 'group', 'member', 'member_groups' ) ); //$activity_content = 'ACTIVITY CONTENT'; $this_user_profile_url = bp_core_get_user_domain($wp_user_id); $action_String = "<a href=\"". $this_user_profile_url ."\">@" . bp_core_get_username($wp_user_id)."</a> has just ratified the new earth treaty"; //add activity to the database bp_activity_add( array( 'user_id' => $wp_user_id, 'action' => $action_String, // 'content' => $activity_content, 'component' => 'nen_treaty_ratified_action', // 'primary_link' => '<a href="'.get_post_permalink($this_activity_id).'">' . $title . '</a>', 'type' => 'custom_activity_update', 'hide_sitewide' => false )); } add_action( 'bp_register_activity_actions', 'nen_register_activity_actions' ); update_user_meta($user_id, 'treaty_ratified', $status ); update_user_meta($user_id, 'treaty_timestamp', $treaty_date ); } else { delete_user_meta($user_id, 'treaty_timestamp'); } }
- You must be logged in to reply to this topic.