Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function give_profile_name($atts){
- $user=wp_get_current_user();
- $name=$user->user_firstname;
- return $name;
- }
- add_shortcode('profile_name', 'give_profile_name');
- add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' );
- function my_dynamic_menu_items( $menu_items ) {
- foreach ( $menu_items as $menu_item ) {
- if ( strpos($menu_item->title, '#profile_name#') !== false) {
- $menu_item->title = str_replace("#profile_name#", wp_get_current_user()->billing_company, $menu_item->title);
- }
- }
- return $menu_items;
- <!-- no campo "billing_company" você muda pra "display_name"... ou outra coisa
- https://codex.wordpress.org/Function_Reference/wp_get_current_user
- no menu você coloca "#profile_name#" sem aspas... -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement