Plugin Directory

Changeset 837902


Ignore:
Timestamp:
01/13/2014 08:25:57 PM (12 years ago)
Author:
jonimo
Message:

1.2.1 added some more options to direct users to profile/edit and to a users homepage

Location:
jonimo-simple-redirect/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • jonimo-simple-redirect/trunk/addons/redirect-default-addon.php

    r837305 r837902  
    4141            }
    4242        }
     43        var_dump($new_default);
    4344        if (array_sum($new_default) == 0){
    4445            echo '<strong>'.admin_url().'</strong><br>';
  • jonimo-simple-redirect/trunk/class/redirect-core.php

    r837305 r837902  
    106106        elseif ( $option === 'bp' ){
    107107             if(function_exists('bp_is_active')){
    108                     global $bp;
    109                     if( $value == 1 ){                   
    110                             //just in case this is depricated...
    111                             if(function_exists('bp_core_get_user_domain')){
    112                             //if we are logged in lets get the domain by the loggedin_user_id
    113                             if (is_user_logged_in()){
    114                             $profile_url = bp_core_get_user_domain( bp_loggedin_user_id() );   
    115                             }
    116                             //if not we use the user object
    117                             else{
    118                             $profile_url = bp_core_get_user_domain( $user->ID );
    119                             }
    120                             return $profile_url;
    121                             }
     108                        global $bp;
     109                        if( $value == 1 ){                   
     110                                //just in case this is depricated...
     111                                if(function_exists('bp_core_get_user_domain')){
     112                                //if we are logged in lets get the domain by the loggedin_user_id
     113                                if (is_user_logged_in()){
     114                                $profile_url = bp_core_get_user_domain( bp_loggedin_user_id() );   
     115                                }
     116                                //if not we use the user object
     117                                else{
     118                                $profile_url = bp_core_get_user_domain( $user->ID );
     119                                }
     120                                return $profile_url;
     121                                }
     122                        }
     123                        elseif( $value === 2 ){
     124                                if(function_exists('bp_get_activity_root_slug')){
     125                                $activity_slug = bp_get_activity_root_slug();
     126                                $activity_url = $bp->root_domain."/".$activity_slug;
     127                                return $activity_url;
     128                                }
     129                        }
     130                        elseif( $value === 3 ){
     131                                if(function_exists('bp_get_activity_root_slug')){
     132                                $activity_slug = bp_get_activity_root_slug();
     133                                $friends_activity = $bp->root_domain."/".$ctivity_slug."/friends/";
     134                                return $friends_activity;
     135                                }
     136                        }
     137                        elseif( $value === 4 ){
     138                                //just in case this is depricated...
     139                                if(function_exists('bp_core_get_user_domain')){
     140                                //if we are logged in lets get the domain by the loggedin_user_id
     141                                if (is_user_logged_in()){
     142                                $profile_url = bp_core_get_user_domain( bp_loggedin_user_id() );   
     143                                }
     144                                //if not we use the user object
     145                                else{
     146                                $profile_url = bp_core_get_user_domain( $user->ID );
     147                                }
     148                                $edit_profile_url .= $profile_url.'profile/edit';
     149                                return $edit_profile_url;
     150                                }
     151                        }
    122152                    }
    123                     elseif( $value === 2 ){
    124                             if(function_exists('bp_get_activity_root_slug')){
    125                             $activity_slug = bp_get_activity_root_slug();
    126                             $activity_url = $bp->root_domain."/".$activity_slug;
    127                             return $activity_url;
    128                             }
    129                     }
    130                     elseif( $value === 3 ){
    131                             if(function_exists('bp_get_activity_root_slug')){
    132                             $activity_slug = bp_get_activity_root_slug();
    133                             $friends_activity = $bp->root_domain."/".$ctivity_slug."/friends/";
    134                             return $friends_activity;
    135                             }
    136                     }
    137                 }
     153        }
    138154                //if buddypress is deactivated or uninstalled, and there is a BP option set, we reset all options to 0 and redirect users to the admin.
    139                 else{
    140                     $args = array();
    141                     $args['page'] = 0;
    142                     $args['categories'] = 0;
    143                     $args['tag'] = 0;
    144                     $args['bp'] = 0;
    145                     update_option( 'jj_register_'.$role_name, $args );
    146                    
    147                     $default_link = admin_url();
    148                     $default = apply_filters( 'ji_filter_default_link' , $default_link, $user );
    149                     return  $default;
    150                 }
    151         }
    152 }
     155        else{
     156            $args = array();
     157            $args['page'] = 0;
     158            $args['categories'] = 0;
     159            $args['tag'] = 0;
     160            $args['bp'] = 0;
     161            update_option( 'jj_register_'.$role_name, $args );
     162
     163            $default_link = admin_url();
     164            $default = apply_filters( 'ji_filter_default_link' , $default_link, $user );
     165            return  $default;
     166        }
     167}
     168
    153169
    154170
  • jonimo-simple-redirect/trunk/class/redirect-login.php

    r837305 r837902  
    2929}
    3030add_action( 'admin_init', 'jj_register_admin_init'); // register the admin
     31
    3132
    3233/**
     
    255256            <?php if ( bp_is_active( 'friends' )) { ?>
    256257            <option value="3" <?php if ( $options['bp'] == 3 ) echo 'selected="selected"'; ?>>Friends Activity</option>
     258            <?php }?>
     259            <?php if ( bp_is_active( 'friends' )) { ?>
     260            <option value="4" <?php if ( $options['bp'] == 4 ) echo 'selected="selected"'; ?>>User profile edit</option>
    257261            <?php }?>
    258262            </select>
  • jonimo-simple-redirect/trunk/class/redirect-logout.php

    r832484 r837902  
    4444                //if the value does not equal -1 i.e it is the one selected..
    4545                if ( $value != 0 ){
    46                    $link = jj_redirect_get_logout_link( $value, $option );
    47                 }
     46                        $link = jj_redirect_get_logout_link( $value, $option );
     47                        if ($link != null ){
     48                        $link = esc_url( $link );
     49                        echo _e('<p>On logout all users will be directed to: <br><strong>'.$link.'</strong><p>');
     50                        }
     51                   }
    4852            }
    49         echo '<p>On logout all users will be directed to: <br><strong>'.$link.'</strong><p>';
     53            if (array_sum($options) == 0){
     54             //if all aptions are 0
     55            echo _e('<p>Select one of the options above to redirect users to on login.<p>');
     56            }
    5057        }
    51          else {
    52             echo '<p>Select one of the options above to redirect users to on logout.<p>';
     58        else {
     59            echo _e('<p>Select one of the options above to redirect users to on logout.<p>');
    5360        }
    5461        ?>   
     
    185192}
    186193 
     194
     195/**
     196 * Adds a homepage option to the wp_dropdown_pages
     197 * Credit goes to http://www.churchthemer.com/ for this bit of code.
     198 * @since 1.2
     199 *
     200 * @return array of valid values
     201 */
     202function jj_dropdown_addhome($output){
     203    $frontpage_id = get_option('page_on_front');
     204    $dropdown = $output;
     205    $homepage = str_replace("<select name='page_id'>","<select name='page_id'><option value=\"$frontpage_id\">Home</option>",$dropdown);
     206    return $homepage;
     207}
     208add_filter('wp_dropdown_pages','jj_dropdown_addhome');
     209
     210
    187211?>
  • jonimo-simple-redirect/trunk/jj_core_setup.php

    r837305 r837902  
    11<?php
    22/*
    3 Plugin Name: Jonimo Simple Redirect
     3Plugin Name: jonimo Simple Redirect
    44Plugin URI: http://www.jonimo.com
    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.2
     7Version: 1.2.1
    88Author: jonimo
    99Author URI: http://www.jonimo.com
  • jonimo-simple-redirect/trunk/readme.txt

    r837305 r837902  
    44Requires at least: 3.0.1
    55Tested up to: 3.8
    6 Stable tag: 1.2
     6Stable tag: 1.2.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1818* NEW Set a default redirect location for any role where a redirect location is not set.
    1919* 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
    20 their personal profile pages, their 'friends' menu or the activity stream
     20their personal profile pages, their 'friends' menu or the activity stream.
    2121* Fully multisite compatible, giving each site administration control over where the different users of their site are redirected to
    2222* Extendable and built with developers in mind. It's easy to change the default redirect behaviour using custom filters.
     
    3434To install:
    3535
    36 1. Upload `ji_redirect` to the `/wp-content/plugins/` directory of your site.
     361. Upload `jonimo_simple_redirect` to the `/wp-content/plugins/` directory of your site.
    37371. Activate the plugin through the 'Plugins' menu in WordPress
    38381. You should be able to see a top level menu called 'Redirect Settings' appear in your administration panel.
Note: See TracChangeset for help on using the changeset viewer.