Really appreciate all the positive feedback about the plugin. Thank you.
Okay, so for now, you can start to achieve your goals with the tube_vc_filter_import_term filter.
Here’s an example, NOT tested but should work or come close! Drop it in your child themes functions.php file or a simple plugin…
add_filter( 'tube_vc_filter_import_term', 'mytube_custom_import_terms' );
function mytube_custom_import_terms( $import_term_ids, $source_site, $creator_name ){
// custom terms per channel
$custom_terms = array(
'youtube-h3h3productions' => array( 420 ),
'vimeo-chicagobears' => array( 9, 34, 72, 95 )
);
// create a slug from source site and creator name
$key = $source_site.'-'.sanitize_title($creator_name);
// if no custom terms, send back original value
if ( ! array_key_exists( $key, $term_map ) ):
return $import_term_ids;
endif;
// return the custom terms for this channel
return $custom_terms[ $key ];
}
Thread Starter
Ryan
(@rrhode)
OK, awesome! I will test that out later. I think I might understand how it should work. Thank you =)
Have you had a chance to test this yet?
Please mark as resolved if so.
Hi dear @tubegtld
I’ve tested the above code and it did not worked in my case.
http://www.ezyfun.com
Have you updated the code to reflect…
a) The channels you’re importing from
b) The term IDs for your site
If not, it’s not going to work. If so, please post your code snippet here.
I’m writing the following code for customize categories for videos imported in my site from youtube channel:
add_filter( ‘tube_vc_filter_import_term’, ‘mytube_custom_import_terms’ );
function mytube_custom_import_terms( $import_term_ids, $source_site, $creator_name ){
// custom terms per channel
$custom_terms = array(
‘youtube-UCq-Fj5jknLsUf-MWSy4_brA’ => array( 420 ),
);
// create a slug from source site and creator name
$key = $source_site.’-‘.sanitize_title($creator_name);
// if no custom terms, send back original value
if ( ! array_key_exists( $key, $term_map ) ):
return $import_term_ids;
endif;
// return the custom terms for this channel
return $custom_terms[ $key ];
}
UCq-Fj5jknLsUf-MWSy4_brA in above code snippet is id of youtube channel for which I want to customize categories.
regards
Please replace 420 with the term ID(s) from your site as that was just an example Term ID.
You can find the ID by viewing the terms on the backend.
For example, here’s a typical looking link for the “uncategorized” category which is almost always term ID 1…
https://www.gamingpc.tube/wp-admin/term.php?taxonomy=category&tag_ID=1
If you need multiple terms, separate with a comma…
'vimeo-chicagobears' => array( 9, 34, 72, 95 )
thanks for your reply dear
Now I’ve applied following code:
add_filter( ‘tube_vc_filter_import_term’, ‘mytube_custom_import_terms’ );
function mytube_custom_import_terms( $import_term_ids, $source_site, $creator_name ){
// custom terms per channel
$custom_terms = array(
‘youtube-UCq-Fj5jknLsUf-MWSy4_brA’ => array(13, 9, 10), //setting categories for T-Series youtube channel
‘youtube-UCxW2EB82hxC8Vtoy7AGn-Cw’ => array(1586, 38, 61, 37), //setting categories for mazaaq raat youtube channel
);
// create a slug from source site and creator name
$key = $source_site.’-‘.sanitize_title($creator_name);
// if no custom terms, send back original value
if ( ! array_key_exists( $key, $term_map ) ):
return $import_term_ids;
endif;
// return the custom terms for this channel
return $custom_terms[ $key ];
}
applying above code nothing changed i.e. when I click on publish in channel from .tube the post was published with the default category
Use the channel name (lowercase w dashes) instead of the channel ID…
$custom_terms = array(
'youtube-t-series' => array(13, 9, 10),
'youtube-mazaaq-raat-official' => array(1586, 38, 61, 37)
);
dear @tubegtld
It is still not working I have tried channel name lowercase with dashes but it is still making default category on publishing the post.
waiting for your reply
regards
Please try this which includes two changes…
– added priority and arg count to add_filter
– Fixed bunk variable name in array_key_exists
Tested and working in dev environment so hoping this resolves it.
add_filter( 'tube_vc_filter_import_term', 'mytube_custom_import_terms', 10, 3 );
function mytube_custom_import_terms( $import_term_ids, $source_site, $creator_name ){
// custom terms per channel
$custom_terms = array(
'youtube-t-series' => array(13, 9, 10),
'youtube-mazaaq-raat-official' => array(1586, 38, 61, 37)
);
// create a slug from source site and creator name
$key = $source_site.'-'.sanitize_title($creator_name);
// if no custom terms, send back original value
if ( ! array_key_exists( $key, $custom_terms ) ):
return $import_term_ids;
endif;
// return the custom terms for this channel
return $custom_terms[ $key ];
}
Bump to see if you’ve tried this out?
Please mark as resolved if so and it’s working for you.
Hi dear I’ve checked it right now but unfortunately it is causing Internal Server Error with following message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, cgiadmin@yourhostingaccount.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Link of print screen is as under:
https://photos.app.goo.gl/4VSSOXfXArmT9mTu1
Is this still an issue?
It seems from your other ticket(s) that your site is back up.
Please mark as resolved if this isn’t an issue.
Thread Starter
Ryan
(@rrhode)
Sorry for the delayed response. I’ve been busy with other sites for clients and haven’t had a chance to work on this one. I put the code you posted in but haven’t gotten it to work properly yet. I’ll try the latest one you posted today and see if I can make it work. Ideally though it would be something I could change from within WP rather than having to edit the code each time but maybe I can code something up for that.