Skip to:
Content
Pages
Categories
Search
Top
Bottom

Redirecting Logged in users to activity..

Viewing 6 replies - 1 through 6 (of 6 total)
  • @bphelp

    Participant

    @yaakhi
    Try this trick:
    BuddyPress Redirect To Profile Trick Using A Landing Page.
    To modify it to redirect to activity just change this line:
    bp_core_redirect( get_option('home') . '/members/' . bp_core_get_username( bp_loggedin_user_id() ) . '/profile' );
    To this if you want personal activity:
    bp_core_redirect( get_option('home') . '/members/' . bp_core_get_username( bp_loggedin_user_id() ) . '/activity' );
    Or to this if you want sitewide activity:
    bp_core_redirect( get_option('home') . '/activity');

    @yaakhi

    Participant

    Sorrry but could not find the line you mentioned 🙁 here is the whole bp_profile_as_homepage_fork.php file `<?php
    /*
    Plugin Name: BP Profile as Homepage Fork
    Description: Sets the user BP Profile as homepage on the site for logged in users. This emulates Facebook.
    Author: Mort3n
    Version: 1.0
    License: GPL2
    */

    /* Copyright 2013 Mort3n

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    */

    /**
    * Redirect logged-in user from site Homepage to Profile
    * @since 1.0
    */
    function bp_profile_as_homepage_fork_homepage(){

    global $bp;

    $selected_role = get_option( ‘bpahpf_role_choice’ );

    //redirection to profile applied to all roles
    if( ” == $selected_role ){
    if( is_user_logged_in() && is_front_page() ){

    wp_redirect( $bp->loggedin_user->domain, 302 );
    exit;
    }
    }
    //redirection to profile applied to all roles EXCEPT selected_role
    else{
    if( !bp_profile_as_homepage_fork_check_user_role( $selected_role ) && is_front_page() ){
    wp_redirect( $bp->loggedin_user->domain, 302 );
    exit;
    }
    }
    }

    /**
    * Redirect after logout
    * @since 1.0
    */
    function bp_profile_as_homepage_fork_logout_redirection(){

    global $bp;

    $redirect = $bp->root_domain;

    wp_logout_url( $redirect );
    }

    /**
    * Checks if a particular user has a role.
    * Returns true if a match was found.
    * Code for this function modified from http://docs.appthemes.com/tutorials/wordpress-check-user-role-function/
    *
    * @param string $role Role name.
    * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
    * @return bool
    */
    function bp_profile_as_homepage_fork_check_user_role( $role, $user_id = null ) {

    if ( is_numeric( $user_id ) )
    $user = get_userdata( $user_id );
    else
    $user = wp_get_current_user();

    if ( empty( $user ) )
    return false;

    return in_array( $role, (array) $user->roles );
    }

    /**
    * Add the admin page to the dashboard menu
    * @since 1.0
    */
    function bp_profile_as_homepage_fork_menu(){

    load_plugin_textdomain( ‘bpahpf-menu’, false, basename( dirname( __FILE__ ) ) . ‘/languages’ );
    add_options_page( __(‘BP Profile as Homepage Fork Settings’, ‘bpahpf-menu’ ), __( ‘BP Profile as Homepage Fork Settings’,’bpahpf-menu’), ‘manage_options’, ‘bpahpfmenu’, ‘bpahpf_settings_page’);
    }

    /**
    * Outputs the settings screen and saves data when submitted
    * @since 1.0
    */
    function bpahpf_settings_page(){

    //check for capability to manage options
    if ( !current_user_can( ‘manage_options’ ) ){

    wp_die( __(‘You do not have sufficient permissions to access this page.’, ‘bpahpf-menu’ ) );

    }

    $opt_name = ‘bpahpf_role_choice’;
    $data_field_name = ‘bpahpf_role_choice’;

    $opt_val = get_option( $opt_name );

    //if nonce checks out then save submitted data
    $nonce=$_REQUEST[‘_wpnonce’];
    if( wp_verify_nonce( $nonce, ‘bpahpf’ ) )
    {
    $opt_val = $_POST[ $data_field_name ];
    update_option( $opt_name, $opt_val );
    ?>
    <div class=”updated”><p><?php _e( ‘Settings saved.’, ‘bpahpf-menu’ ); ?></p></div>
    <?php

    }

    echo ‘<div class=”wrap”>’;
    echo “<h2>” . __( ‘BP Profile as Homepage Fork Settings’, ‘bpahpf-menu’ ) . “</h2>”;
    ?>
    <p>
    <?php _e( ‘Disable Profile as Homepage for a particular user role.’, ‘bpahpf-menu’ ); ?>
    </p>
    <form name=”bpahpf-settings-form” method=”post” action=””>
    <?php wp_nonce_field( ‘bpahpf’ ); ?>
    <p><b>
    <?php _e( ‘You have selected:’, ‘bpahpf-menu’ ); ?>
    </b>
    <?php
    if ( ” == $opt_val )
    _e( ‘No One’, ‘bpahpf-menu’ );
    else
    echo $opt_val;
    ?>
    <hr />
    <?php _e( ‘Who can view Homepage:’, ‘bpahpf-menu’ ); ?>
    <select name=”<?php echo $data_field_name; ?>”>
    <option value=””>
    <?php _e( ‘No One’, ‘bpahpf-menu’ ); ?>
    </option>
    <?php wp_dropdown_roles( );?>
    </select>
    </p>
    <p class=”submit”>
    <input type=”submit” name=”Submit” class=”button-primary” value=”<?php esc_attr_e( ‘Save Changes’, ‘bpahpf-menu’ ) ?>” />
    </p>
    </form>
    </div>
    <?php
    }

    add_action(‘admin_menu’,’bp_profile_as_homepage_fork_menu’);
    add_action(‘wp’,’bp_profile_as_homepage_fork_homepage’);
    add_action(‘wp_logout’,’bp_profile_as_homepage_fork_logout_redirection’);
    ?>

    @bphelp

    Participant

    @yaakhi
    The link to my solution above is an alternative so it would not be in that plugin. If you had followed the link and read the instructions you would have have known it goes in bp-custom.php and has nothing to do with that plugin.

    @yaakhi

    Participant

    @bphelp but where exactly is bp-custom.php? sorry i could never ind it 🙁

    @aces

    Participant

    @yaakhi

    Participant

    Thank you it worked.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Redirecting Logged in users to activity..’ is closed to new replies.
Skip to toolbar