PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.3
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.3
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
automatorwp / integrations / buddypress / includes / actions / add-user-activity.php

add-user-activity.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 6.0.3, at integrations/buddypress/includes/actions/add-user-activity.php

103 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Add User Activity
4 *
5 * @package AutomatorWP\Integrations\BuddyPress\Actions\Add_User_Activity
6 * @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]>
7 * @since 1.0.0
8 */
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 class AutomatorWP_BuddyPress_Add_User_Activity extends AutomatorWP_Integration_Action {
13
14 public $integration = 'buddypress';
15 public $action = 'buddypress_add_user_activity';
16
17 /**
18 * Register the trigger
19 *
20 * @since 1.0.0
21 */
22 public function register() {
23
24 automatorwp_register_action( $this->action, array(
25 'integration' => $this->integration,
26 'label' => __( 'Add an activity to the user', 'automatorwp' ),
27 'select_option' => __( 'Add an <strong>activity</strong> to the user', 'automatorwp' ),
28 /* translators: %1$s: Activity. */
29 'edit_label' => sprintf( __( 'Add an %1$s to the user', 'automatorwp' ), '{activity}' ),
30 /* translators: %1$s: Activity. */
31 'log_label' => sprintf( __( 'Add an %1$s to the user', 'automatorwp' ), '{activity}' ),
32 'options' => array(
33 'activity' => array(
34 'default' => __( 'activity', 'automatorwp' ),
35 'fields' => array(
36 // Note: "action" key is reserved
37 'activity_action' => array(
38 'name' => __( 'Action:', 'automatorwp' ),
39 'desc' => __( 'Activity\'s action.', 'automatorwp' ),
40 'type' => 'text',
41 'default' => ''
42 ),
43 'content' => array(
44 'name' => __( 'Content:', 'automatorwp' ),
45 'desc' => __( 'Activity\'s content.', 'automatorwp' ),
46 'type' => 'wysiwyg',
47 'default' => ''
48 ),
49 'link' => array(
50 'name' => __( 'Link:', 'automatorwp' ),
51 'desc' => __( 'URL link associated to the activity.', 'automatorwp' ),
52 'type' => 'text',
53 'default' => ''
54 ),
55 'hide_sitewide' => array(
56 'name' => __( 'Hide on the sitewide activity stream:', 'automatorwp' ),
57 'desc' => __( 'Check this option to hide this activity from the sitewide activity stream.', 'automatorwp' ),
58 'type' => 'checkbox',
59 'classes' => 'cmb2-switch'
60 ),
61 )
62 )
63 ),
64 ) );
65
66 }
67
68 /**
69 * Action execution function
70 *
71 * @since 1.0.0
72 *
73 * @param stdClass $action The action object
74 * @param int $user_id The user ID
75 * @param array $action_options The action's stored options (with tags already passed)
76 * @param stdClass $automation The action's automation object
77 */
78 public function execute( $action, $user_id, $action_options, $automation ) {
79
80 // Shorthand
81 $activity_action = $action_options['activity_action'];
82 $content = $action_options['content'];
83 $link = $action_options['link'];
84 $hide = $action_options['hide_sitewide'];
85
86 // Add the activity to the user
87 bp_activity_add( array(
88 'action' => $activity_action,
89 'content' => $content,
90 'component' => 'automatorwp',
91 'type' => 'activity_update',
92 'primary_link' => $link,
93 'user_id' => $user_id,
94 'item_id' => false,
95 'secondary_item_id' => false,
96 'hide_sitewide' => (bool) $hide,
97 ) );
98
99 }
100
101 }
102
103 new AutomatorWP_BuddyPress_Add_User_Activity();