[ SYSTEM ]: Linux wordpress 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
[ SERVER ]: Apache/2.4.66 (Debian) | PHP: 8.2.30
[ USER ]: www-data | IP: 172.19.30.54
GEFORCE FILE MANAGER
/
var
/
www
/
html
/
wordpress
/
wp-content
/
plugins
/
suretriggers
/
src
/
Integrations
/
wordpress
/
actions
/
UPLOAD:
NAME
SIZE
QUICK PERMS
ACTIONS
📄 add-new-media.php
3,538 B
SET
[ EDIT ]
|
[ DEL ]
📄 add-new-role.php
1,974 B
SET
[ EDIT ]
|
[ DEL ]
📄 add-tag-to-post.php
3,028 B
SET
[ EDIT ]
|
[ DEL ]
📄 add-taxonomy-to-post.php
5,804 B
SET
[ EDIT ]
|
[ DEL ]
📄 find-user-by-email.php
2,361 B
SET
[ EDIT ]
|
[ DEL ]
📄 find-user-by-id.php
2,281 B
SET
[ EDIT ]
|
[ DEL ]
📄 find-user-meta-by-key.php
2,308 B
SET
[ EDIT ]
|
[ DEL ]
📄 find-user-metas.php
2,068 B
SET
[ EDIT ]
|
[ DEL ]
📄 get-taxonomy-by-name.php
2,030 B
SET
[ EDIT ]
|
[ DEL ]
DELETE SELECTED
[ CLOSE ]
EDIT: add-new-role.php
<?php /** * AddNewRole. * php version 5.6 * * @category AddNewRole * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Wordpress\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use WP_User; use Exception; /** * AddNewRole * * @category AddNewRole * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class AddNewRole extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'WordPress'; /** * Action name. * * @var string */ public $action = 'add_new_role'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Role: Add a new role to the user\'s roles', 'suretriggers' ), 'action' => 'add_new_role', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * @return bool|array * @throws Exception Exception. */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $field = reset( $fields ); $user = new WP_User( $user_id ); if ( ! ( $user instanceof WP_User ) ) { return [ 'status' => 'error', 'message' => 'This user is not type of WP_User', ]; } $user->add_role( $selected_options[ $field['name'] ] ); return (array) $user; } } AddNewRole::get_instance();