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
- 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
- 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
- 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
- Wrap each shortcode in array to div
- Recent post display using shortcode
- 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
- 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
- Swapping wp_dropdown_categories function with wp_category_checklist
- How to output a PHP file values by shortcode?
- 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)
- Custom shortcode outputs plain text instead of HTML at top of post
- Pass php dynamic variable to shortcode
- Remove echo from shortcode
- php function to display commenter username or login
- 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?
- Plugin Generate Unexpected output during activation
- Shortcode from a function not working
- 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
- Shortcode to find and replace URL
- Help with WordPress function inside a shortcode
- calling a custom field value inside functions.php
- Custom meta box values are not getting saved for my custom post type
- how to save checkbox data for custom setting?
- WordPress shortcode returns the data before
- Shortcode to embed Edit Account form not working
- Shortcode for Listing Users from Meta Value?
- Cant display an image via PHP in wordpress
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- Call to undefined function error in plugin
- Execute Jquery when a specific page in my plugin is loading
- What is the difference between Null vs Empty (Zero Length) string?
- AJAX function not working [closed]
- send popup after wp_redirect()
- Using ACF Relationship field to set post type to draft or published status
- How to change basename url for wp-admin?
- Display Visual Composer shortcode if a post belongs in specific categories
- Why is the current page loaded in the pop-up window and not the specified one?
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- Only the first image uploads
- Block error message in foreach loop when looping through ACF field
- Illegal string offset checkbox
- Custom plugin: how do I call a PHP file if settings option is set to true?
- How can I prevent a shortcode div from extending beyond its boundaries?
- PHP multiple forms, same page, isset($_POST[]) not working?
- Gravity Forms: How to add PHP function to confirmation conditional shortcode?
- wpdb->query returns different value to phpMyAdmin
- shortcodes, custom php and their errors
- How can i avoid duplicate same post in wp?
- 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 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
- Taxonomy Child Term, Counter is staying on 0
- Offset with ajax load more posts duplicates
- Get posts by id using shortcode
- Shortcode’s output to use as other shortcode’s parameter
- PHP get_category() function redeclared
- Shortcode Works for Logged in Users but Not Working for Guest
- Need help with PHP functions
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Permission error on plugin save
- Shortcoding with Divs
- Issues separating my Plugin pages into different files
- My title is showing after the shortcode
- Shortcode to include PHP file, pass various parameters to include?
- How do I change the Go To Categories link in the term_updated_messages
- How call WordPress shortcode inside function file
- Show Login Errors In WordPress/Elementor (Code “works”, but breaks site)