WF_SETUSERTAG::set_user_tag( $user_id, $action_data, $recipe_id, $args )
Validation function when the action is hit
Contents
Parameters Parameters
- $user_id
-
(Required)
- $action_data
-
(Required)
- $recipe_id
-
(Required)
Source Source
File: src/integrations/wp-fusion/actions/wf-setusertag.php
public function set_user_tag( $user_id, $action_data, $recipe_id ) { if ( ! empty( $user_id ) ) { // is the use in DB? $contact_id = wp_fusion()->user->get_contact_id( $user_id, true ); // if not lets add then if ( false === $contact_id ) { wp_fusion()->user->user_register( $user_id ); } // get tag yo set $tag = sanitize_text_field( $action_data['meta'][ $this->action_meta ] ); // us get_tag_id to id the real ID or return the tag so that this works with all CMS $tag = wp_fusion()->user->get_tag_id( $tag ); $current_tags = wp_fusion()->user->get_tags( $user_id ); // check we don't have the tag if ( ! in_array( $tag, $current_tags, true ) ) { // add tag wp_fusion()->user->apply_tags( array( $tag ), $user_id ); } } else { $error_msg = Automator()->error_message->get( 'not-logged-in' ); Automator()->complete_action( $user_id, $action_data, $recipe_id, $error_msg ); return; } Automator()->complete_action( $user_id, $action_data, $recipe_id ); }
Expand full source code Collapse full source code View on Github