so i'm trying create 2 categories when user logs in. need category names username of user logging in.
i'm new php , i've been looking through codex , know how user information can't figure out how make output in array or title.
the current code below closest i've gotten. works except php code not outputting. shows blank after creation process.
function login_createinitialcategories($user_login, $user) { $current_user = wp_get_current_user(); wp_insert_term( '<?php echo $current_user->user_login; ?>', 'outings', array( 'description' => '<?php echo $current_user->user_login ; ?> outings', 'slug' => '<?php echo $current_user->user_login ; ?>-category' ) ); wp_insert_term( '<?php echo $current_user->user_login ; ?>', 'adventures', array( 'description' => '<?php echo $current_user->user_login ; ?> adventures', 'slug' => '<?php echo $current_user->user_login ; ?>-category' ) ); } add_action('wp_login', 'login_createinitialcategories', 10, 2);
do guys know way around this? code working perfectly, it's not responding/outputting php code.
below link picture of result of code above. (i of posted here, don't have enough reputation.)
https://www.dropbox.com/s/wamd6q3vd0odv7w/2015-05-08_02h52_10.png?dl=0
what below code gives ??
function login_createinitialcategories($user_login, $user) { $current_user = wp_get_current_user(); $user_login = $current_user->user_login; wp_insert_term( $user_login, //your term 'outings', //your taxonomy array( 'description' => $user_login.' outings', 'slug' => $user_login.'-category' ) ); wp_insert_term( $user_login, 'adventures', array( 'description' => $user_login.' adventures', 'slug' => $user_login.'-category' ) ); } add_action('wp_login', 'login_createinitialcategories', 10, 2);
Comments
Post a Comment