• This is a pretty tiny adjustment I am hoping to make, but is all the difference in the world. For my multisite network I want site owners to each have their own gallery on their page. However, they will only have the one gallery, which is built in to their page template when they register. This means that the ability to create multiple galleries is unnecessary and will only confuse people. All I am really hoping to do is hide the link that says “add new gallery” under the add gallery/images link, all the other areas for controlling can be handled through adminimize. How can this be done?

    Also if possible could I set a default gallery for “in to” on that page?

    http://wordpress.org/extend/plugins/nextgen-gallery/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ktrusak

    (@ktrusak)

    Here is a screenshot to help explain

    View post on imgur.com

    I have removed the “Add new gallery” tab (and two other tabs) using a function which hooks into a filter in wp-content/plugins/nextgen-gallery/admin/addgallery.php.

    I put this code in my functions.php file in my theme:

    if (!current_user_can('publish_posts') ) {
    
    	add_filter('ngg_addgallery_tabs', 'test_remove_tabs');
    
    	function test_remove_tabs ($tabs) {
    		unset($tabs['addgallery']);
    		unset($tabs['zipupload']);
    		unset($tabs['importfolder']);
    		return $tabs;
    	}
    
    }

    The if (!current_user_can('publish_posts') {} conditional restricts this to users below Author level ie Contributors. To use another level see the WordPress Roles and Capabilities.

    I have hidden the “Choose gallery” select option and set it to the current user’s own, single gallery by hacking wp-content/plugins/nextgen-gallery/admin/addgallery.php. It would be better to do it without a hack but I don’t know how!

    The idea is to serve a hidden field to Contributors with their gallery id drawn from the database as the value:

    if (!current_user_can('publish_posts') ) {
    				global $current_user, $wpdb;
    				get_currentuserinfo();
    				$user_gallery = $wpdb->get_var( $wpdb->prepare( "SELECT gid FROM wp_ngg_gallery WHERE name = %s", $current_user->user_login ) ); ?>
    				<input name="galleryselect" id="galleryselect" type="hidden" value="<?php echo $user_gallery; ?>" />

    … then Authors and above get the standard code – a select menu in a table row…

    <?php } else { ?>
    			<tr valign="top">
    				<th scope="row"><?php _e('in to', 'nggallery') ;?></th>
    				<td><select name="galleryselect" id="galleryselect">
    				<option value="0" ><?php _e('Choose gallery', 'nggallery') ?></option>
    				<?php
    					foreach($this->gallerylist as $gallery) {
    
    						//special case : we check if a user has this cap, then we override the second cap check
    						if ( !current_user_can( 'NextGEN Upload in all galleries' ) )
    							if ( !nggAdmin::can_manage_this_gallery($gallery->author) )
    								continue;
    
    						$name = ( empty($gallery->title) ) ? $gallery->name : $gallery->title;
    						echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr( $name ) . '</option>' . "\n";
    					}					?>
    				</select>
    				<br /><?php echo $this->maxsize; ?>
    				<br /><?php if ((is_multisite()) && wpmu_enable_function('wpmuQuotaCheck')) display_space_usage(); ?></td>
    			</tr>
    			<?php }

    I have done a similar thing to the ‘Scale images to max width…” checkbox in order to reduce the number of choices for my Contributors.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: NextGEN Gallery] Removing the "add-new" link’ is closed to new replies.