Plugin Directory

Changeset 837305


Ignore:
Timestamp:
01/12/2014 07:00:53 PM (12 years ago)
Author:
jonimo
Message:

Version 1.2

Location:
jonimo-simple-redirect/trunk
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • jonimo-simple-redirect/trunk/class/redirect-core.php

    r832484 r837305  
    162162 */
    163163function jj_redirect_get_logout_link( $value, $option ) {
     164        global $user;
    164165        if( $option == 'categories' ){
    165166        $uri = get_category_link( $value );
  • jonimo-simple-redirect/trunk/class/redirect-login.php

    r832484 r837305  
    4242        <h3>Select a role from a tab below</h3>
    4343        <?php
    44         $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : '';
     44        $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : jj_get_default_role();
    4545    $wp_roles = new WP_Roles();
    4646    $roles = $wp_roles->get_names();
     
    102102function jj_redirect_page_select(){
    103103        //set the active as administrator if no other tab setting is indiacted in the GET array.
    104         $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'administrator';
     104        $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : jj_get_default_role();
    105105    $wp_roles = new WP_Roles();
    106106    $roles = $wp_roles->get_names();
     
    138138function jj_redirect_category_select(){?>
    139139        <?php
    140         $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'administrator';
     140        $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : jj_get_default_role();
    141141    $wp_roles = new WP_Roles();
    142142    $roles = $wp_roles->get_names();
     
    186186 */
    187187function jj_redirect_tag_select(){
    188         $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'administrator';
     188        $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : jj_get_default_role();
    189189    $wp_roles = new WP_Roles();
    190190    $roles = $wp_roles->get_names();
     
    235235function jj_redirect_bp_select(){?>
    236236        <?php
    237         $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'administrator';
     237        $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : jj_get_default_role();
    238238        //Lets get the roles
    239239    $wp_roles = new WP_Roles();
     
    291291function jj_display_selected_link($role_name) {
    292292    global $user;
     293   
     294    //we get the options
    293295    $options = get_option( 'jj_register_'.$role_name);
    294     if ( $options ){
     296    if ( $options ){       
    295297        foreach ( $options as $option => $value ){
    296              //if the value does not equal 0 i.e it is the one selected..
     298                //if the value does not equal 0 i.e it is the one selected..
    297299                if ($value != 0){
    298300                    $link = jj_redirect_get_login_link( $redirect_url = null , $request_url = null, $user, $value, $option, $role_name);
     
    301303                    $link = esc_url( $link );
    302304                        echo _e('<p>On login these users will be directed to: <br><strong>'.$link.'</strong><p>');
     305                        break;
    303306                    }
     307                   
    304308                    //if we dont return a link (despite a value being passed to jj_redirect_get_login_link
    305309                    else {
    306310                        echo _e('<p>Select one of the options above to redirect users to on login.<p>');
    307311                    }
    308                }
     312               } 
    309313         }
     314    if (array_sum($options) == 0){
     315         //if all aptions are 0
     316        echo _e('<p>Select one of the options above to redirect users with the role of "'.$role_name.'" to on login.
     317        <br>If no option is set these users will be directed to the default link below.<p>');
     318        jj_redirect_get_default_link($user);
     319    }
    310320    }
    311321    //if there are no options set...
    312322    else {
    313         echo _e('<p>Select one of the options above to redirect users to on login.<p>');
     323        echo _e('<p>Select one of the options above to redirect users with the role of "'.$role_name.'" to on login.
     324        <br>If no option is set these users will be directed to the default link below.<p>');
     325        jj_redirect_get_default_link($user);
     326       
    314327    }
    315328}
  • jonimo-simple-redirect/trunk/jj_core_setup.php

    r832484 r837305  
    55Description: Redirect different users based on their role, to any page, tag or category on login or logout.
    66 * If you have buddypress installed, redirect users to their profile, their activity or their friends activity tabs.
    7 Version: 1.1
     7Version: 1.2
    88Author: jonimo
    99Author URI: http://www.jonimo.com
     
    1515require_once( plugin_dir_path(__FILE__) . 'class/redirect-login.php' );
    1616require_once( plugin_dir_path(__FILE__) . 'class/redirect-logout.php' );
     17require_once( plugin_dir_path(__FILE__) . 'class/redirect-default.php' );
     18require_once( plugin_dir_path(__FILE__) . 'addons/redirect-default-addon.php' );
    1719//require_once( plugin_dir_path(__FILE__) . 'class/redirect-settings.php' );
    1820add_action( 'admin_menu', 'jj_redirect_admin_menu' );
     
    4850        'manage_options', 'jonimo', 'jj_redirect_display_settings_page',
    4951        plugins_url( 'assets/images/ji_redirect.png', __FILE__ ) );
    50          add_submenu_page( 'jonimo', 'Login', 'Login', 'manage_options',
     52        //check what the first role is and append this to the
     53        add_submenu_page( 'jonimo', 'Login', 'Login', 'manage_options',
    5154        'jonimo', 'jj_redirect_display_settings_page' );
    5255        add_submenu_page( 'jonimo', 'Logout', 'Logout', 'manage_options',
    53         __FILE__.'_logout', 'jj_redirect_display_logout_page' );
     56        'logout', 'jj_redirect_display_logout_page' );
    5457        //add_submenu_page( __FILE__, 'Settings', 'Settings', 'manage_options',
    5558        //__FILE__.'_settings', 'ji_redirect_display_settings' );
     59        add_submenu_page( 'jonimo', 'Default Link', 'Default Link', 'manage_options',
     60        'default', 'jj_redirect_display_default_page' );
    5661        add_submenu_page( 'jonimo', 'About', 'About', 'manage_options',
    5762        __FILE__.'_about', 'jj_redirect_display_about_page' );
    58 
    5963}
    6064
     
    6468function jj_redirect_display_about_page() {
    6569    ?>
    66 <div class="wrap">
     70    <div class="wrap">
    6771    <?php screen_icon(); ?>
    6872    <h2>About</h2>
     
    7175    and bpdev for some ideas that led to parts of this code being written. You can find his great work on <a href ="">www.buddydev.com</a>
    7276    </p>
    73 </div>
     77    </div>
    7478    <?php
    7579}
    7680
    7781
     82function jj_get_default_role(){
     83        $wp_roles = new WP_Roles();
     84    $roles = $wp_roles->get_names();
     85        foreach ($roles as $role_value => $role_name) {
     86        return $role_name;
     87        }
     88}
     89
    7890
    7991?>
  • jonimo-simple-redirect/trunk/readme.txt

    r832973 r837305  
    11=== Plugin Name ===
    22Contributors: jonimo
    3 Tags: redirect, login, logout, buddypress, multisite, profile, page, tag, category
     3Tags: redirect, login, logout, buddypress, multisite, profile, page, tag, user roles
    44Requires at least: 3.0.1
    55Tested up to: 3.8
    6 Stable tag: 1.1
     6Stable tag: 1.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414jonimo simple redirect helps your users with different roles get to the right place when they login or logout of your WordPress site.
    1515
    16 * seamlessly redirect different users to different areas of your website based on their role
    17 * simply select a role, then one page, content category or content tag to send these users to on login
    18 * fully compatible with BuddyPress 1.9. You can give your users an experience more similar to popular social networks by redirecting them to
     16* Seamlessly redirect different users to different areas of your website based on their role.
     17* NEW Simply select a role, then one page, content category or content tag to send users to on login.
     18* NEW Set a default redirect location for any role where a redirect location is not set.
     19* Fully compatible with Wordpress 3.8 and BuddyPress 1.9.1 You can give your users an experience more similar to popular social networks by redirecting them to
    1920their personal profile pages, their 'friends' menu or the activity stream
    20 * fully multisite compatible, giving each site administration control over where the different users of their site are redirected to
    21 * extendable and built with developers in mind. It's easy to change the default redirect behaviour using custom filters.
     21* Fully multisite compatible, giving each site administration control over where the different users of their site are redirected to
     22* Extendable and built with developers in mind. It's easy to change the default redirect behaviour using custom filters.
    2223
    2324Coming in 2014:
     
    4546
    4647Any other plugin that attempts to redirect users on login or logout may conflict with this plugin. Likewise, any plugin that uses a
    47 custom login script such as woocommerce may cause jonimo simple redirect to be ineffective.
     48custom login script may cause jonimo simple redirect to be ineffective.
    4849We are looking at ways to ensure as wide a compatability as possible in upcoming releases. If you have any problems, please let us know at
    4950[jonimo](http://jonimo.com/forums/support "jonimo support")
     
    7071== Screenshots ==
    7172
    72 1. login
    73 2. logout
     731. On the login options screen you can choose where to redirect different users based on their role.
     742. On the logout options screen you can direct all users to a common location.
    7475
    7576== Changelog ==
    7677
     78= 1.2 =
     79* You can now select a unique default place for users to be redirected to on login if no custom destination has been set for their role.
     80* Improved messaging
     81
    7782= 1.1 =
    78 * You can now select different redirect options for different roles.
    79 * Tested on BuddyPress 1.9 and WordPress 3.8
     83* You can now select different redirect destination for users based on their role.
     84* Tested on BuddyPress 1.9 and 3.8
    8085* Added more filters for developers
    8186
  • jonimo-simple-redirect/trunk/uninstall.php

    r832484 r837305  
    99delete_option( 'jj_register_'.$role_name);
    1010}
     11
     12//delete the default link option on uninstall.
     13delete_option('jj_redirect_default');
     14
    1115?>
Note: See TracChangeset for help on using the changeset viewer.