BuddyDev

Search

[Resolved] change css with php in wordpress / buddypress

  • Participant
    Level: Initiated
    Posts: 2
    Craig Seidl on #111

    Hello Buddy Dev community,

    I’m very new to php coding and I’ve been trying very hard to get this to work.

    I’m using wedevs project managment plugin with buddypress integration. There dev team doesn’t have the time to customize the plugin for me at the moment so I’m looking for a quick fix. I feel I’m so close but for some reason I’m not getting it to work.

    I have a “create project” button in groups that I would like to hide for all group members accept the Group admin. so I would like it to verify if the user is the group admin and show the “create project link”. But if it is just a group member or user I would like the “create project link” to be hidden.

    Only group admins should be allowed to create projects… Here is what I have so far. But its not working. Any help or guidance would be greatly appreciated.

    here is what I have so far, with that buddypress check, I’m able to hide or show to all users but I cant get it to only show for the group admin.

    <?php if ( BP_Groups_Member::get_is_admin_of( $user_id )) { ?>
    <style type=”text/css” media=”screen”>
    .cpm-projects nav.cpm-new-project a {visibility:visible; }
    </style>
    <?php } else { ?>
    <style type=”text/css” media=”screen”>
    .cpm-projects nav.cpm-new-project a {visibility:hidden; }
    </style>
    <?php } ?>

    Keep in mind that the stylesheet for the plugin has this inside the style sheet.

    .cpm-projects nav.cpm-new-project a {
    background: transparent url(“../images/plus.png”) no-repeat scroll 50% 50%;
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.3);
    height: 80px;
    width: 80px;
    display: block;
    border-radius: 3px;
    }

    I’ve tried all of these calls and still cant get it to work

    if ( BP_Groups_Member::get_is_admin_of( $user_id )) {

    if ( ! groups_is_user_admin( $user_id, $group_id ) ) {

    if ( groups_is_user_admin( $user_id, $group_id ) ) {

    if ( groups_is_user_admin( get_current_user_id(), $group_id ) ) {

    Any advice or help would be greatly appreciated.

  • Participant
    Level: Initiated
    Posts: 2
    Craig Seidl on #112

    PS. I’ve tried modifying the entire plugin by adding another permission setting but its way to advanced for me. So I’m trying to do a quick fix by just hiding the button with CSS. I understand its not the best way to do things but I’m just looking for a quick simple fix.

    Thanks!

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #113

    Hi Craig,
    Welcome to the BuddyDev forum.

    Here is a function that you can call anywhere(may be in header or footer) and It will hide the link

    
    function bpdev_custom_hide_link_css() {
    
    	$group = groups_get_current_group();
    	
    	if( empty( $group ) ) {
    		return ;//we are not at group page
    	}
    	//if the current user is not group admin, let us hide it
    	if( ! groups_is_user_admin( get_current_user_id(), bp_get_group_id() ) ) { 
    	?>
    	<style type="text/css">
    		.cpm-projects nav.cpm-new-project a{
    			display: none !important;//hide by overriding any other display layout
    		}
    	</style>
    	<?php
    	}
    
    }
    

    To call it, you can do like this

    
    <?php bpdev_custom_hide_link_css();?>
    

    Can you please give it a try and let me know if this works or not?

  • Participant
    Level: Initiated
    Posts: 2
    Craig Seidl on #114

    oh my god you are a genius!

    I cant thank you enough! You are forever in my good graces Brajesh. When I’m worth a billion dollars someday, I will make sure to take care of you. I promise!

    Have a wonderful week and I appreciate you taking the time out of your day to help!

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #115

    Hi Craig,
    Thank you for the kind words. These are worth more happiness than any money can buy 🙂

    Have a wonderful week to you too and happy social networking with BuddyPress:)

You must be logged in to reply to this topic.

This topic is: resolved