Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Function to check if a specific tag was applied and update user meta with the current URL.
- *
- * @param int $user_id The ID of the user.
- * @param array $tags An array of tags applied.
- */
- function update_user_meta_with_url_on_tag_application( $user_id, $tags ) {
- // Get the tag ID for "DS - Free Course Check"
- $tag_id = wpf_get_tag_id( 'DS - Free Course Check' );
- // Check if the tag is in the array of applied tags
- if ( in_array( $tag_id, $tags, true ) ) {
- // Get the current URL's relative path from $_SERVER variables
- $current_url = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
- // Update the user meta
- update_user_meta( $user_id, 'url_tag_applied', $current_url );
- }
- }
- add_action( 'wpf_tags_applied', 'update_user_meta_with_url_on_tag_application', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement