Use PHP ternary comparsion operator to check if get_user_meta()
function returns blank or non-blank result:
function colaborador_nome($atts) {
if (is_user_logged_in() && !is_feed()) {
return ' '. (get_user_meta( get_current_user_id(), 'first_name', true ) ?: "Hi >No Name<, please settle your name in your account.");
}
}
add_shortcode('colaborador_nome', 'colaborador_nome');
Related Posts:
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- Making Quote Plugin more efficient
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- WP Custom tables query
- How to manually fix the WordPress gallery code using PHP in functions.php?
- Displaying Logged-In User Name in WordPress Menu
- Fatal error: Call to undefined function plugin_dir_path()
- Shortcode putting html such as
- Retrieve multiple values passed to a single attribute in a shortcode
- Dynamic URL to reference custom PHP files
- Display a text message if the shortcode is not found?
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Shortcode created to check language not works
- Add/echo div with Analytics-Code to function in functions.php
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- Loading page template into shortcode
- My shortcode is showing up twice
- How can I default to all WordPress roles when parameter is not included in shortcode?
- WordPress menu deletes when trying to add a hook
- Using wp_get_image_editor in a standalone script
- New Plugin Review
- Wrap each shortcode in array to div
- Recent post display using shortcode
- Nested shortCode functions in the functions.php file
- How to access function from outside of a class within this class in WP plugin?
- Placing raw HTML inside a WordPress shortcode
- PHP can I add line numbers to file_get_contents()
- custom shortcode will not display the wrapped content
- Shortcode content output but not in correct place
- is_page “range” for if statement?
- PHP code inside shortcodes
- Shortcode content filter?
- Trigger popup in a php if/else statement
- Adding Default Settings to Theme My Login plugin
- Append HTML Using Shortcode
- Plugin CSS not enqueing
- Swapping wp_dropdown_categories function with wp_category_checklist
- How to output a PHP file values by shortcode?
- Showing content from one page on another
- How to access global variable $menu inside a class function
- How to display posts by current user in a drop down
- How can I remove a function that has been added to wordpress with add_filter?
- Get value from shortcode to do something
- what is the best practice to add new field to an api route
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- How to call plugin function per site in a multisite?
- Custom shortcode outputs plain text instead of HTML at top of post
- Pass php dynamic variable to shortcode
- How to Reference/Echo Variable from Another PHP Function
- Remove echo from shortcode
- php function to display commenter username or login
- WordPress Custom field Colors
- Redirect to another page using contact form 7? [closed]
- Shortcode with PHP issue “Undefined index”
- How to obtain the current website URL in my theme?
- What exactly do this function declared into functions.php file of a WP theme?
- How to use html inside a functions.php code?
- Plugin Generate Unexpected output during activation
- Shortcode from a function not working
- Display Data in Table from External Database in WP using Shortcodes
- Is it possible to return content, and then also continue to do other things?
- ::before on open/close function [closed]
- Using data sent via AJAX in multiple functions on a WP plugin
- Creating WordPress Shortcode with Variable
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- How to override theme’s public static function inside of a trait?
- overwrite wordpress gallery with custom gallery shortcode
- Enqueue sripts and styles only if function is called
- How to return html as a string from php for WordPress
- post_exists stops working in a scheduled event
- Display current user metadata on WordPress page
- Reload page with a different shortcode when a user selects from a dropdown
- How Can I Display the Last Modified Date for User Profiles on WordPress?
- Taxonomy Child Term, Counter is staying on 0
- How to auto-generate random numbers in username?
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Offset with ajax load more posts duplicates
- Get posts by id using shortcode
- Shortcode’s output to use as other shortcode’s parameter
- Open/closed function [closed]
- Need to Echo A Url path to show on a wordpress page
- PHP get_category() function redeclared
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- Shortcode Works for Logged in Users but Not Working for Guest
- Wrapping shortcode content in a span or link
- Need help with PHP functions
- Private messaging – Getting and displaying the avatar/url of a message recipient
- How to have Function of a plugin using global vars into a shortcode?
- Permission error on plugin save
- Overwriting a Shortcode
- Shortcoding with Divs
- Trouble using wordpress functions in a pop-up modal form
- Issues separating my Plugin pages into different files
- Whats wrong with my code? Need To add String to shortcode? [closed]
- My title is showing after the shortcode
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- A next page function with shortcode?
- Shortcode to include PHP file, pass various parameters to include?