Last active
February 3, 2025 13:42
-
-
Save yuriinalivaiko/b15e6ba6c0b5dfd2185e7d4fa6015a5c to your computer and use it in GitHub Desktop.
Code snippets for the "Followers" extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Automatically follow the brand profile on registration. | |
| add_action( 'um_registration_set_extra_data', function( $user_id, $args ) { | |
| if ( defined( 'um_followers_version' ) ) { | |
| // all new members will "follow" this brand profile. | |
| $brand_user_id = 1; | |
| if ( UM()->Followers_API()->api()->can_follow( $brand_user_id, $user_id ) ) { | |
| UM()->Followers_API()->api()->add( $brand_user_id, $user_id ); | |
| } | |
| } | |
| }, 20, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Hide the "Followers" extension elements for guests. | |
| if ( ! is_user_logged_in() && defined('um_followers_version') ) { | |
| // A bar in profile. | |
| remove_action( 'um_profile_navbar_content', 'um_followers_add_profile_bar', 4 ); | |
| remove_action( 'um_profile_navbar', 'um_followers_add_profile_bar', 4 ); | |
| // Button and stats in the directory. | |
| remove_action( 'um_members_just_after_name_tmpl', array( UM()->Followers_API()->member_directory(), 'followers_stats' ), 1 ); | |
| remove_action( 'um_members_just_after_name_tmpl', array( UM()->Followers_API()->member_directory(), 'followers_button' ), 101 ); | |
| remove_action( 'um_members_list_after_user_name_tmpl', array( UM()->Followers_API()->member_directory(), 'followers_stats' ), 1 ); | |
| remove_action( 'um_members_list_just_after_actions_tmpl', array( UM()->Followers_API()->member_directory(), 'followers_button' ), 101 ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment