Skip to:
Content

BuddyPress.org

Changeset 13125


Ignore:
Timestamp:
10/10/2021 11:46:17 AM (5 years ago)
Author:
imath
Message:

Introduce filters to allow custom redirection URL on activated account

  • bp_members_invitations_activation_errored_redirect can be used to customize the URL to redirect the user to if activating the invitation failed.
  • bp_members_invitations_activation_successed_redirect can be used for the same purpose but on a successful activated account.
  • bp_members_action_activate_errored_redirect can be used to customize the URL to redirect the user to if activating the account failed.
  • bp_members_action_activate_successed_redirect can be used for the same purpose but on a successful activated account.

NB: this commit also makes sure the bp_get_activation_page() is used to build the activation page url instead of rebuilding this URL from the activate actions.

Fixes #8542

Location:
trunk/src/bp-members
Files:
2 edited

Legend:

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

    r13105 r13125  
    126126        $key = bp_get_user_meta( $user_id, 'activation_key', true );
    127127        if ( $key ) {
     128                $redirect = bp_get_activation_page();
     129
    128130                /**
    129131                 * Filters the activation signup.
     
    138140                // If there were errors, add a message and redirect.
    139141                if ( ! empty( $user->errors ) ) {
     142                        /**
     143                         * Filter here to redirect the User to a different URL than the activation page.
     144                         *
     145                         * @since 10.0.0
     146                         *
     147                         * @param string   $redirect The URL to use to redirect the user.
     148                         * @param WP_Error $user     The WP Error object.
     149                         */
     150                        $redirect = apply_filters( 'bp_members_invitations_activation_errored_redirect', $redirect, $user );
     151
    140152                        bp_core_add_message( $user->get_error_message(), 'error' );
    141                         bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
     153                        bp_core_redirect( $redirect );
    142154                }
    143155
     156                /**
     157                 * Filter here to redirect the User to a different URL than the activation page.
     158                 *
     159                 * @since 10.0.0
     160                 *
     161                 * @param string $redirect The URL to use to redirect the user.
     162                 */
     163                $redirect = apply_filters( 'bp_members_invitations_activation_successed_redirect', $redirect );
     164
    144165                bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
    145                 bp_core_redirect( add_query_arg( 'activated', '1', bp_get_activation_page() ) );
     166                bp_core_redirect( add_query_arg( 'activated', '1', $redirect ) );
    146167        }
    147168}
  • trunk/src/bp-members/screens/activate.php

    r11927 r13125  
    8686        }
    8787
    88         $bp = buddypress();
     88        $bp       = buddypress();
     89        $redirect = bp_get_activation_page();
    8990
    9091        /**
     
    100101        // If there were errors, add a message and redirect.
    101102        if ( ! empty( $user->errors ) ) {
     103                /**
     104                 * Filter here to redirect the User to a different URL than the activation page.
     105                 *
     106                 * @since 10.0.0
     107                 *
     108                 * @param string   $redirect The URL to use to redirect the user.
     109                 * @param WP_Error $user     The WP Error object.
     110                 */
     111                $redirect = apply_filters( 'bp_members_action_activate_errored_redirect', $redirect, $user );
     112
    102113                bp_core_add_message( $user->get_error_message(), 'error' );
    103                 bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
     114                bp_core_redirect( $redirect );
    104115        }
    105116
     117        /**
     118         * Filter here to redirect the User to a different URL than the activation page.
     119         *
     120         * @since 10.0.0
     121         *
     122         * @param string $redirect The URL to use to redirect the user.
     123         */
     124        $redirect = apply_filters( 'bp_members_action_activate_successed_redirect', $redirect );
     125
    106126        bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
    107         bp_core_redirect( add_query_arg( 'activated', '1', bp_get_activation_page() ) );
     127        bp_core_redirect( add_query_arg( 'activated', '1', $redirect ) );
    108128
    109129}
Note: See TracChangeset for help on using the changeset viewer.