Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/24/2014 02:30:41 AM (12 years ago)
Author:
tw2113
Message:

Add hook documentation in bp-members-functions.php.

Props tw2113.
See #5944.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r9231 r9270  
    140140        }
    141141
     142        /**
     143         * Filters the results of the user query.
     144         *
     145         * @since BuddyPress (1.2.0)
     146         *
     147         * @param array $retval Array of users for the current query.
     148         * @param array $r      Array of parsed query arguments.
     149         */
    142150        return apply_filters( 'bp_core_get_users', $retval, $r );
    143151}
     
    169177        $domain       = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login );
    170178
     179        /**
     180         * Filters the domain for the passed user.
     181         *
     182         * @since BuddyPress (1.0.1)
     183         *
     184         * @param string $domain        Domain for the passed user.
     185         * @param int    $user_id       ID of the passed user.
     186         * @param string $user_nicename User nicename of the passed user.
     187         * @param string $user_login    User login of the passed user.
     188         */
    171189        return apply_filters( 'bp_core_get_user_domain', $domain, $user_id, $user_nicename, $user_login );
    172190}
     
    187205                wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' );
    188206        }
     207
     208        /**
     209         * Filters the userdata for a passed user.
     210         *
     211         * @since BuddyPress (1.2.0)
     212         *
     213         * @param array $userdata Array of user data for a passed user.
     214         */
    189215        return apply_filters( 'bp_core_get_core_userdata', $userdata );
    190216}
     
    219245        $user = get_user_by( 'login', $username );
    220246
     247        /**
     248         * Filters the ID of a user, based on user_login.
     249         *
     250         * @since BuddyPress (1.0.1)
     251         *
     252         * @param int|null $value    ID of the user or null.
     253         * @param string   $username User login to check.
     254         */
    221255        return apply_filters( 'bp_core_get_userid', ! empty( $user->ID ) ? $user->ID : NULL, $username );
    222256}
     
    237271        $user = get_user_by( 'slug', $user_nicename );
    238272
     273        /**
     274         * Filters the user ID based on user_nicename.
     275         *
     276         * @since BuddyPress (1.2.3)
     277         *
     278         * @param int|null $value         ID of the user or null.
     279         * @param string   $user_nicename User nicename to check.
     280         */
    239281        return apply_filters( 'bp_core_get_userid_from_nicename', ! empty( $user->ID ) ? $user->ID : NULL, $user_nicename );
    240282}
     
    311353        }
    312354
     355        /**
     356         * Filters the username based on originally provided user ID.
     357         *
     358         * @since BuddyPress (1.0.1)
     359         *
     360         * @param string $username Username determined by user ID.
     361         */
    313362        return apply_filters( 'bp_core_get_username', $username );
    314363}
     
    368417        }
    369418
     419        /**
     420         * Filters the user_nicename based on originally provided user ID.
     421         *
     422         * @since BuddyPress (1.5.0)
     423         *
     424         * @param string $username User nice name determined by user ID.
     425         */
    370426        return apply_filters( 'bp_members_get_user_nicename', $user_nicename );
    371427}
     
    395451        }
    396452
     453        /**
     454         * Filters the user email for user based on user ID.
     455         *
     456         * @since BuddyPress (1.0.1)
     457         *
     458         * @param string $email Email determined for the user.
     459         */
    397460        return apply_filters( 'bp_core_get_user_email', $email );
    398461}
     
    432495        }
    433496
     497        /**
     498         * Filters the link text for the passed in user.
     499         *
     500         * @since BuddyPress (1.2.0)
     501         *
     502         * @param string $value   Link text based on passed parameters.
     503         * @param int    $user_id ID of the user to check.
     504         */
    434505        return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>', $user_id );
    435506}
     
    551622        }
    552623
     624        /**
     625         * Filters the display name for the passed in user.
     626         *
     627         * @since BuddyPress (1.0.1)
     628         *
     629         * @param string $fullname Display name for the user.
     630         * @param int    $user_id  ID of the user to check.
     631         */
    553632        return apply_filters( 'bp_core_get_user_displayname', $fullname, $user_id );
    554633}
     
    566645function bp_core_get_userlink_by_email( $email ) {
    567646        $user = get_user_by( 'email', $email );
     647
     648        /**
     649         * Filters the user link for the user based on user email address.
     650         *
     651         * @since BuddyPress (1.0.1)
     652         *
     653         * @param string|bool $value URL for the user if found, otherwise false.
     654         */
    568655        return apply_filters( 'bp_core_get_userlink_by_email', bp_core_get_userlink( $user->ID, false, false, true ) );
    569656}
     
    583670        }
    584671
     672        /**
     673         * Filters the user link for the user based on username.
     674         *
     675         * @since BuddyPress (1.0.1)
     676         *
     677         * @param string|bool $value URL for the user if found, otherwise false.
     678         */
    585679        return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
    586680}
     
    606700        }
    607701
     702        /**
     703         * Filters the total number of members for the installation.
     704         *
     705         * @since BuddyPress (1.2.0)
     706         *
     707         * @param int $count Total number of members.
     708         */
    608709        return apply_filters( 'bp_core_get_total_member_count', $count );
    609710}
     
    634735        }
    635736
     737        /**
     738         * Filters the total number of members for the installation limited to those with last_activity.
     739         *
     740         * @since BuddyPress (1.6.0)
     741         *
     742         * @param int $count Total number of active members.
     743         */
    636744        return apply_filters( 'bp_core_get_active_member_count', $count );
    637745}
     
    713821                // Call multisite actions in single site mode for good measure
    714822                if ( !is_multisite() ) {
    715                         $wp_action = ( true === $is_spam ) ? 'make_spam_user' : 'make_ham_user';
    716                         do_action( $wp_action, bp_displayed_user_id() );
     823                        if ( true === $is_spam ) {
     824
     825                                /**
     826                                 * Fires at end of processing spammer in Dashboard if not multisite and user is spam.
     827                                 *
     828                                 * @since BuddyPress (1.5.0)
     829                                 *
     830                                 * @param int $value Displayed user ID.
     831                                 */
     832                                do_action( 'make_spam_user', bp_displayed_user_id() );
     833                        } else {
     834
     835                                /**
     836                                 * Fires at end of processing spammer in Dashboard if not multisite and user is not spam.
     837                                 *
     838                                 * @since BuddyPress (1.5.0)
     839                                 *
     840                                 * @param int $value Displayed user ID.
     841                                 */
     842                                do_action( 'make_ham_user', bp_displayed_user_id() );
     843                        }
     844
     845
    717846                }
    718847        }
     
    724853
    725854        // We need a special hook for is_spam so that components can delete data at spam time
    726         $bp_action = ( true === $is_spam ) ? 'bp_make_spam_user' : 'bp_make_ham_user';
    727         do_action( $bp_action, $user_id );
    728 
    729         // Allow plugins to do neat things
     855        if ( true === $is_spam ) {
     856
     857                /**
     858                 * Fires at the end of the process spammer process if the user is spam.
     859                 *
     860                 * @since BuddyPress (1.5.0)
     861                 *
     862                 * @param int $value Displayed user ID.
     863                 */
     864                do_action( 'bp_make_spam_user', $user_id );
     865        } else {
     866
     867                /**
     868                 * Fires at the end of the process spammer process if the user is not spam.
     869                 *
     870                 * @since BuddyPress (1.5.0)
     871                 *
     872                 * @param int $value Displayed user ID.
     873                 */
     874                do_action( 'bp_make_ham_user', $user_id );
     875        }
     876
     877        /**
     878         * Fires at the end of the process for hanlding spammer status.
     879         *
     880         * @since BuddyPress (1.5.5)
     881         *
     882         * @param int  $user_id ID of the processed user.
     883         * @param bool $is_spam The determined spam status of processed user.
     884         */
    730885        do_action( 'bp_core_process_spammer_status', $user_id, $is_spam );
    731886
     
    815970        }
    816971
     972        /**
     973         * Filters whether a user is marked as a spammer.
     974         *
     975         * @since BuddyPress (1.6.0)
     976         *
     977         * @param bool $is_spammer Whether or not user is marked as spammer.
     978         */
    817979        return apply_filters( 'bp_is_user_spammer', (bool) $is_spammer );
    818980}
     
    8721034        }
    8731035
     1036        /**
     1037         * Filters whether a user is marked as deleted.
     1038         *
     1039         * @since BuddyPress (1.6.0)
     1040         *
     1041         * @param bool $is_deleted Whether or not user is marked as deleted.
     1042         */
    8741043        return apply_filters( 'bp_is_user_deleted', (bool) $is_deleted );
    8751044}
     
    10561225        }
    10571226
     1227        /**
     1228         * Filters the last activity for a given user.
     1229         *
     1230         * @since BuddyPress (1.9.0)
     1231         *
     1232         * @param string $activity Time of last activity, in 'Y-m-d H:i:s' format or
     1233         *                         an empty string if none found.
     1234         * @param int    $user_id  ID of the user being checked.
     1235         */
    10581236        return apply_filters( 'bp_get_user_last_activity', $activity, $user_id );
    10591237}
     
    11421320        }
    11431321
     1322        /**
     1323         * Fires before the processing of an account deletion.
     1324         *
     1325         * @since BuddyPress (1.6.0)
     1326         *
     1327         * @param int $user_id ID of the user account being deleted.
     1328         */
    11441329        do_action( 'bp_core_pre_delete_account', $user_id );
    11451330
     
    11571342        }
    11581343
     1344        /**
     1345         * Fires after the deletion of an account.
     1346         *
     1347         * @since BuddyPress (1.6.0)
     1348         *
     1349         * @param int $user_id ID of the user account that was deleted.
     1350         */
    11591351        do_action( 'bp_core_deleted_account', $user_id );
    11601352
     
    13331525        }
    13341526
    1335         // Add our slugs to the array and allow them to be filtered
     1527        /**
     1528         * Filters the array of default illegal usernames.
     1529         *
     1530         * @since BuddyPress (1.2.2)
     1531         *
     1532         * @param array $value Merged and unique array of illegal usernames.
     1533         */
    13361534        $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) );
    13371535
     
    13421540        $illegal_names          = array_unique( (array) $merged_names );
    13431541
     1542        /**
     1543         * Filters the array of default illegal names.
     1544         *
     1545         * @since BuddyPress (1.2.5)
     1546         *
     1547         * @param array $value Merged and unique array of illegal names.
     1548         */
    13441549        return apply_filters( 'bp_core_illegal_names', $illegal_names );
    13451550}
     
    14531658                $errors = new WP_Error();
    14541659
    1455                 // Apply any user_login filters added by BP or other plugins before validating
     1660                /**
     1661                 * Filters the username before being validated.
     1662                 *
     1663                 * @since BuddyPress (1.5.5)
     1664                 *
     1665                 * @param string $user_name Username to validate.
     1666                 */
    14561667                $user_name = apply_filters( 'pre_user_login', $user_name );
    14571668
     
    15171728        }
    15181729
     1730        /**
     1731         * Filters the result of the user signup validation.
     1732         *
     1733         * @since BuddyPress (1.2.2)
     1734         *
     1735         * @param array $result Results of user validation including errors, if any.
     1736         */
    15191737        return apply_filters( 'bp_core_validate_user_signup', $result );
    15201738}
     
    15341752        }
    15351753
     1754        /**
     1755         * Filters the validated blog url and title provided at signup.
     1756         *
     1757         * @since BuddyPress (1.2.2)
     1758         *
     1759         * @param array $value Array with the new site data and error messages.
     1760         */
    15361761        return apply_filters( 'bp_core_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );
    15371762}
     
    15981823                BP_Signup::add( $args );
    15991824
     1825                /**
     1826                 * Filters if BuddyPress should send an activation key for a new signup.
     1827                 *
     1828                 * @since BuddyPress (1.2.3)
     1829                 *
     1830                 * @param bool   $value          Whether or not to send the activation key.
     1831                 * @param int    $user_id        User ID to send activation key to.
     1832                 * @param string $user_email     User email to send activation key to.
     1833                 * @param string $activation_key Activation key to be sent.
     1834                 * @param array  $usermeta       Miscellaneous metadata about the user (blog-specific
     1835                 *                               signup data, xprofile data, etc).
     1836                 */
    16001837                if ( apply_filters( 'bp_core_signup_send_activation_key', true, $user_id, $user_email, $activation_key, $usermeta ) ) {
    16011838                        bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key );
     
    16051842        $bp->signup->username = $user_login;
    16061843
     1844        /**
     1845         * Fires at the end of the process to sign up a user.
     1846         *
     1847         * @since BuddyPress (1.2.2)
     1848         *
     1849         * @param bool|WP_Error   $user_id       True on success, WP_Error on failure.
     1850         * @param string          $user_login    Login name requested by the user.
     1851         * @param string          $user_password Password requested by the user.
     1852         * @param string          $user_email    Email address requested by the user.
     1853         * @param array           $usermeta      Miscellaneous metadata about the user (blog-specific
     1854         *                                       signup data, xprofile data, etc).
     1855         */
    16071856        do_action( 'bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta );
    16081857
     
    16251874        }
    16261875
     1876        /**
     1877         * Filters the result of wpmu_signup_blog()
     1878         *
     1879         * This filter provides no value and is retained for
     1880         * backwards compatibility.
     1881         *
     1882         * @since BuddyPress (1.2.2)
     1883         *
     1884         * @param void $value
     1885         */
    16271886        return apply_filters( 'bp_core_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );
    16281887}
     
    17261985
    17271986                if ( isset( $user_already_created ) ) {
     1987
     1988                        /**
     1989                         * Fires if the user has already been created.
     1990                         *
     1991                         * @since BuddyPress (1.2.2)
     1992                         *
     1993                         * @param int    $user_id ID of the user being checked.
     1994                         * @param string $key     Activation key.
     1995                         * @param array  $user    Array of user data.
     1996                         */
    17281997                        do_action( 'bp_core_activated_user', $user_id, $key, $user );
    17291998                        return $user_id;
     
    17612030        }
    17622031
     2032        /**
     2033         * Fires at the end of the user activation process.
     2034         *
     2035         * @since BuddyPress (1.2.2)
     2036         *
     2037         * @param int    $user_id ID of the user being checked.
     2038         * @param string $key     Activation key.
     2039         * @param array  $user    Array of user data.
     2040         */
    17632041        do_action( 'bp_core_activated_user', $user_id, $key, $user );
    17642042
     
    19282206        $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
    19292207
     2208        /**
     2209         * Filters the avatar storage directory for use during registration.
     2210         *
     2211         * @since BuddyPress (1.1.1)
     2212         *
     2213         * @param array $value Array of path and URL values for created storage directory.
     2214         */
    19302215        return apply_filters( 'bp_core_signup_avatar_upload_dir', array(
    19312216                'path'    => $path,
     
    19522237        $subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
    19532238
    1954         // Send the message
     2239        /**
     2240         * Filters the user email that the validation email will be sent to.
     2241         *
     2242         * @since BuddyPress (1.5.0)
     2243         *
     2244         * @param string $user_email User email the notification is being sent to.
     2245         * @param int    $user_id    ID of the new user receiving email.
     2246         */
    19552247        $to      = apply_filters( 'bp_core_signup_send_validation_email_to',     $user_email, $user_id                );
     2248
     2249        /**
     2250         * Filters the validation email subject that will be sent to user.
     2251         *
     2252         * @since BuddyPress (1.5.0)
     2253         *
     2254         * @param string $subject Email validation subject text.
     2255         * @param int    $user_id ID of the new user receiving email.
     2256         */
    19562257        $subject = apply_filters( 'bp_core_signup_send_validation_email_subject', $subject,    $user_id                );
     2258
     2259        /**
     2260         * Filters the validation email message that will be sent to user.
     2261         *
     2262         * @since BuddyPress (1.5.0)
     2263         *
     2264         * @param string $message      Email validation message text.
     2265         * @param int    $user_id      ID of the new user receiving email.
     2266         * @param string $activate_url URL to use for activating account.
     2267         */
    19572268        $message = apply_filters( 'bp_core_signup_send_validation_email_message', $message,    $user_id, $activate_url );
    19582269
    19592270        wp_mail( $to, $subject, $message );
    19602271
     2272        /**
     2273         * Fires after the sending of activation email to a newly registered user.
     2274         *
     2275         * @since BuddyPress (1.5.0)
     2276         *
     2277         * @param string $subject    Subject for the sent email.
     2278         * @param string $message    Message for the sent email.
     2279         * @param int    $user_id    ID of the new user.
     2280         * @param string $user_email Email address of the new user.
     2281         * @param string $key        Activation key.
     2282         */
    19612283        do_action( 'bp_core_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key );
    19622284}
     
    21272449                );
    21282450
    2129                 // setup login URL
     2451                /**
     2452                 * Filters the url used for redirection for a logged in user marked as spam.
     2453                 *
     2454                 * @since BuddyPress (1.8.0)
     2455                 *
     2456                 * @param string $value URL to redirect user to.
     2457                 */
    21302458                $login_url = apply_filters( 'bp_live_spammer_redirect', add_query_arg( $args, wp_login_url() ) );
    21312459
     
    22612589         * @param array  $types     Member type objects, keyed by name.
    22622590         * @param array  $args      Array of key=>value arguments for filtering.
    2263          * @param string $operator 'or' to match any of $args, 'and' to require all.
     2591         * @param string $operator  'or' to match any of $args, 'and' to require all.
    22642592         */
    22652593        $types = apply_filters( 'bp_get_member_types', $types, $args, $operator );
Note: See TracChangeset for help on using the changeset viewer.