Use something like
echo WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
This will give you the URL to your plugin directory.
Ta r-a-y <img src="smileys/heart.gif" width="" height="" alt="<3" title="
@r-a-y last thing, Ive changed my mind a bit when it comes to the options. How could I get it to check the values seperated by a ,
Say the db field ready: one,two
The thing is it might read “one,three” or “two,four” so there should be a way for it to check separating it by a comma? Other wise I would have to type out all the instances that might occur..
// check which option is in the db
$group_card = groups_get_groupmeta( $group->id, 'gcard_group_card' );
if ($group_card == 'one'){
$group_card = gcard_one();
}
if ($group_card == 'two'){
$group_card = gcard_two();
}
return apply_filters( 'gcard_get_group_card', $group_card );
}
Make sure you save the groupmeta as an array or as a comma-delimited entry.
Then you can do your check with in_array() or strpos().
Edit: Iv’e come right using the last method ( thanks r-a-y for all your halp..again <img src="smileys/heart.gif" width="" height="" alt="<3" title=" )
@r-a-y Ive gotten the value’s to save an an array, example from my db: a:2:{i:0;s:3:”one”;i:1;s:3:”two”;}
Now I take it I have to use steralize, while Im reading up on that.. have I used in_array correctly as Im finding info hard to come by?
$group_card = groups_get_groupmeta( $group->id, 'gcard_group_card' );
if (in_array($group_card == 'one')){
$group_card = gcard_one();
}
if (in_array($group_card == 'two')){
$group_card = gcard_two();
}
return apply_filters( 'gcard_get_group_card', $group_card );
}
or should it look more like:
if(in_array("one",$group_card)){
echo gcard_one();
}
Glad it worked for you.
FYI, you don’t need to serialize or unserialize arrays since BP does that automatically for you when you cache meta!
@r-a-y miester last of the last thing
Im getting a error for groups that dont have the db field
Warning: in_array() expects parameter 2 to be array, string given in F:Programmesxampphtdocswordpresswp-contentpluginsbuddypress-group-credit-cardsbp-group-credit-cards.php on line 101
Would saying ‘else return something’ be the right path, and what should I return to avoid the error?
Edit, thinking about it, how would I say if ‘gcard_group_card’ doesn’t exist, don’t return anuthing?
If there is no saved setting for the meta, you should declare a blank array.
eg.
$my_meta == groups_get_groupmeta(….);
if ( empty($my_meta) )
$my_meta = array();
@r-a-y I’ve given it my all but no matter what I try I can’t get it to work for groups that don’t have the meta-data. Think I may have layed out “Get or return the card values” wrong. I know Im starting to irritate you abit with this one though this is the last step in a working plug-in
Ive made it echo “one”, “two”.. for now so that you don’t have to have the images to work with it. Think you could take a look?
Here’s the plugin: http://pastebin.com/aFkPfJwW
Edit: Iv’e though of away around this for now, adding a nother function, function gcard_none() and just making it return “we are not associated with any image..” I would just have to make one of the fields compulsory
You didn’t declare the empty array like I mentioned above:
http://pastebin.com/z13rhwYx
Bleh.. @r-a-y, soz about that. I did use the same as what you suggested in your above post. Was still giving the error till I created a new group, maybe I should have cleared cache and everything.. ( will def remember now )
Thank you though for all your help!