Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/01/2011 01:33:09 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Adjustments to login and register forms to improve behavior and functionality.
Various documentation fixes.
Rename _bbp_topic_status meta to _bbp_status, and add migration routine to updater.
Sanity checks on $wp_query in bbp_pre_get_posts.

Fixes #1476, #1493. Props GautamGupta for original diff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-user-template.php

    r2914 r2970  
    146146        global $user_identity;
    147147
    148         if ( is_user_logged_in() )
    149             $current_user_name = $user_identity;
    150         else
    151             $current_user_name = __( 'Anonymous', 'bbpress' );
     148        $current_user_name = is_user_logged_in() ? $user_identity : __( 'Anonymous', 'bbpress' );
    152149
    153150        return apply_filters( 'bbp_get_current_user_name', $current_user_name );
     
    538535     * @param int $user_id Optional. User id
    539536     * @uses bbp_get_user_profile_url() To get the user profile url
    540      * @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the
    541      *                        user profile url and user id
     537     * @uses apply_filters() Calls 'bbp_get_subscriptions_permalink' with
     538     *                        the user profile url and user id
    542539     * @return string Permanent link to user subscriptions page
    543540     */
     
    759756    global $bbp;
    760757
    761     return _wp_get_user_contactmethods( $bbp->displayed_user );
     758    // Get the core WordPress contact methods
     759    $contact_methods = _wp_get_user_contactmethods( $bbp->displayed_user );
     760
     761    return apply_filters( 'bbp_edit_user_contact_methods', $contact_methods );
    762762}
    763763
    764764/** Login *********************************************************************/
     765
     766/**
     767 * Handle the login and registration template notices
     768 *
     769 * @since bbPress (r2970)
     770 */
     771function bbp_login_notices() {
     772    global $bbp;
     773
     774    // loggedout was passed
     775    if ( !empty( $_GET['loggedout'] ) && ( true == $_GET['loggedout'] ) ) {
     776        $bbp->errors->add( 'loggedout', __( 'You are now logged out.', 'bbpress' ), 'message' );
     777
     778    // registration is disabled
     779    } elseif ( !empty( $_GET['registration'] ) && ( 'disabled' == $_GET['registration'] ) ) {
     780        $bbp->errors->add( 'registerdisabled', __( 'New user registration is currently not allowed.', 'bbpress' ) );
     781
     782    // Prompt user to check their email
     783    } elseif ( !empty( $_GET['checkemail'] ) && in_array( $_GET['checkemail'], array( 'confirm', 'newpass', 'registered' ) ) ) {
     784
     785        switch ( $_GET['checkemail'] ) {
     786
     787            // Email needs confirmation
     788            case 'confirm' :
     789                $bbp->errors->add( 'confirm',    __( 'Check your e-mail for the confirmation link.',     'bbpress' ), 'message' );
     790                break;
     791
     792            // User requested a new password
     793            case 'newpass' :
     794                $bbp->errors->add( 'newpass',    __( 'Check your e-mail for your new password.',         'bbpress' ), 'message' );
     795                break;
     796
     797            // User is newly registered
     798            case 'registered' :
     799                $bbp->errors->add( 'registered', __( 'Registration complete. Please check your e-mail.', 'bbpress' ), 'message' );
     800                break;
     801        }
     802    }
     803}
    765804
    766805/**
     
    779818 */
    780819function bbp_logged_in_redirect( $url = '' ) {
     820
     821    // Bail if user is not logged in
    781822    if ( !is_user_logged_in() )
    782823        return;
    783824
     825    // Setup the profile page to redirect to
    784826    $redirect_to = !empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() );
     827
     828    // Do a safe redirect and exit
    785829    wp_safe_redirect( $redirect_to );
    786830    exit;
     
    813857 * @since bbPress (r2815)
    814858 *
     859 * @uses bbp_login_url() To get the login url
     860 * @uses bbp_redirect_to_field() To output the redirect to field
    815861 * @uses wp_nonce_field() To generate hidden nonce fields
    816862 */
     
    818864?>
    819865
    820         <input type="hidden" name="action"      value="bbp-user-register" id="bbp_user_register" />
     866        <input type="hidden" name="action"      value="register" />
    821867        <input type="hidden" name="user-cookie" value="1" />
     868
     869        <?php bbp_redirect_to_field( add_query_arg( array( 'checkemail' => 'registered' ), bbp_login_url() ) ); ?>
    822870
    823871        <?php wp_nonce_field( 'bbp-user-register' );
     
    862910     *
    863911     * @param mixed $args Optional. If an integer, it is used as reply id.
    864      * @uses bbp_get_reply_id() To get the reply id
    865912     * @uses bbp_is_topic() To check if it's a topic page
     913     * @uses bbp_get_topic_author_link() To get the topic author link
    866914     * @uses bbp_is_reply() To check if it's a reply page
     915     * @uses bbp_get_reply_author_link() To get the reply author link
     916     * @uses get_post_field() To get the post author
    867917     * @uses bbp_is_reply_anonymous() To check if the reply is by an
    868918     *                                 anonymous user
    869      * @uses bbp_get_reply_author() To get the reply author name
    870      * @uses bbp_get_reply_author_url() To get the reply author url
    871      * @uses bbp_get_reply_author_avatar() To get the reply author avatar
     919     * @uses get_the_author_meta() To get the author name
     920     * @uses bbp_get_user_profile_url() To get the author profile url
     921     * @uses get_avatar() To get the author avatar
    872922     * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
    873923     *                        author link and args
Note: See TracChangeset for help on using the changeset viewer.