-
I have the bookmarks plugin and I was wondering how I might add another standard collection to the list of collections. Just to clarify, there is a standard collection that you can name in the admin section and I would just like to add a second one to be a default collection.
Love your plugins!
If I can get the direction on how to do this I can do it myself, it doesn’t need to be a complete change of the plugin. I have added the field in the admin area for a second set but I cant figure out how to add it to the array as a default.
Thank you for your time.
Hi williamr, can you verify purchase here first? 🙂 And please show me what you tried already so I can understand what are you trying to do
Hi william,
you need to hook/integrate your custom collection here: collection_options API function in api.php 🙂
See the options list, integrate yours somewhere there.
You are talking about here, line 162:
/* Get collections for user */
function collection_options($default_collection, $post_id){
$output = ”;
$user_id = get_current_user_id();
$collections = $this->get_collections($user_id);
$bookmarks = (array) get_user_meta($user_id, ‘_userpro_bookmarks’, true);
if (isset($bookmarks[$post_id])){
$cur_collection = $bookmarks[$post_id];
} else {
$cur_collection = 0;
}
foreach($collections as $k => $v) {
if (!isset($v[‘label’])) $v[‘label’] = $default_collection;
$output .= ‘<option value=”‘.$k.'” ‘.selected($k, $cur_collection, 0).’ >’.$v[‘label’];
$output .= ‘</option>’;
}
return $output;
}But I’m not sure what to do to add what I need to, sorry.
Thank you, like this right:
function collection_options($default_collection, $post_id){
$output = ”;
$user_id = get_current_user_id();
$collections = $this->get_collections($user_id);
$bookmarks = (array) get_user_meta($user_id, ‘_userpro_bookmarks’, true);
if (isset($bookmarks[$post_id])){
$cur_collection = $bookmarks[$post_id];
} else {
$cur_collection = 0;
}
$output .= ‘default_collection2’;
foreach($collections as $k => $v) {
if (!isset($v[‘label’])) $v[‘label’] = $default_collection;
$output .= ‘<option value=”‘.$k.'” ‘.selected($k, $cur_collection, 0).’ >’.$v[‘label’];
$output .= ‘</option>’;
}
return $output;
}Just tried and it did not work. Have any other suggestions 🙂
You must be logged in to reply to this topic.