bp_add_activation_redirect()
Redirect user to BP’s What’s New page on first page load after activation.
Description
Source
File: bp-core/bp-core-update.php
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | function bp_add_activation_redirect() { // Bail if activating from network, or bulk. if ( isset( $_GET [ 'activate-multi' ] ) ) { return ; } // Record that this is a new installation, so we show the right // welcome message. if ( bp_is_install() ) { set_transient( '_bp_is_new_install' , true, 30 ); } // Check in Current DB having a below 2 options are saved for the BBPress Topic & Topic Reply previously. $topic_slug = get_option( '_bbp_topic_slug' ); $topic_tag_slug = get_option( '_bbp_topic_tag_slug' ); $topic_archive_slug = get_option( '_bbp_topic_archive_slug' ); if ( empty ( $topic_slug ) ) { // Check if there is any topics their in DB. $topics = get_posts( array ( 'post_type' => 'topic' , 'numberposts' => 1 ) ); // If found the topics then go ahead. if ( ! empty ( $topics ) ) { // Topics found so set the _bbp_topic_slug to "topic" instead of "discussion" otherwise it will create the issue who used previously BBPress. update_option( '_bbp_topic_slug' , 'topic' ); // Set Flag to enable Forums default. update_option( 'bbp_set_forum_to_default' , 'yes' ); // Get current active component. $bp_active_components = get_option( 'bp-active-components' , array () ); if ( ! in_array( 'forums' , $bp_active_components ) ) { // Add Forums to current components. $bp_active_components [ 'forums' ] = 1; // Set the forums to in DB. bp_update_option( 'bp-active-components' , $bp_active_components ); } // If Forums page is not set. $option = bp_get_option( '_bbp_root_slug_custom_slug' , '' ); if ( '' === $option ) { $default_title = bp_core_get_directory_page_default_titles(); $title = ( isset( $default_title [ 'new_forums_page' ] ) ) ? $default_title [ 'new_forums_page' ] : '' ; $new_page = array ( 'post_title' => $title , 'post_status' => 'publish' , 'post_author' => bp_loggedin_user_id(), 'post_type' => 'page' , 'comment_status' => 'closed' , 'ping_status' => 'closed' , ); // Create Forums Page. $page_id = wp_insert_post( $new_page ); bp_update_option( '_bbp_root_slug_custom_slug' , $page_id ); $slug = get_post_field( 'post_name' , $page_id ); // Set BBPress root Slug bp_update_option( '_bbp_root_slug' , $slug ); } // Reset the permalink. bp_update_option( 'rewrite_rules' , '' ); } if ( empty ( $topic_archive_slug ) ) { update_option( '_bbp_topic_archive_slug' , 'topics' ); } if ( empty ( $topic_tag_slug ) ) { // Tags found so set the _bbp_topic_tag_slug to "topic-reply" instead of "discussion-reply" otherwise it will create the issue who used previously BBPress. update_option( '_bbp_topic_tag_slug' , 'topic-tag' ); } } // Add the transient to redirect. set_transient( '_bp_activation_redirect' , true, 30 ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.7.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.