You will want to add the hook function in your functions.php file:
$user = wp_get_current_user();
if($user->exists) {
add_filter('public_link_root', function() { return 'example.com'; } );
}
Then whenever you are working with a URL in any of your template files, you can allow the URL to be modified by your customer filter public_link_root
. The filter will only run if the user exists, otherwise the URL won’t be altered.
So in your template files:
$some_link = apply_filters('public_link_root', 'ourwebsite.com') . '/resources';
echo '<a href="' . $some_link . '">View Resources</a>';
For this to make more sense, you should spend some time reading the documentation and example code on add_filter and apply_filters.
Related Posts:
- start_lvl Ignored in Custom walker_nav_menu
- Enforcing password complexity
- Customize default settings on new sites on multisite
- Check if a menu is empty?
- Dynamically change feature image in customiser
- Creating wordpress user registration form
- Remove class that has been added by parent theme
- category not display in word press grammatically
- Setting up the child theme so as to enable right-to-left WordPress?
- Design view breaking on Pages
- Getting a fatal error while updating
- Hooking new functions to actions + passing parameters
- my function doesn’t return my post from today
- How to break down importing of feeds
- Create Logout Link WordPress Admin Menu
- get_the_terms – only top level
- Have CSS Class Added with `is_page()` WP function
- Slide in Panel WordPress Post
- Use wp_get_recent_posts with search term
- Calculations in functions.php [closed]
- comments_number display outside specified span
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Get_avatar filter?
- Passing the custom field values in the wp_get_current_user array function
- Get value from shortcode to do something
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- How to create a php variable using WordPress the_title() function
- Can’t find infinite loop cause
- how to make custom ajax handler?
- How to disable controls in theme customizer?
- register_taxonomy() take much queries
- is there a benefit in using a constant over get_stylesheet_directory_uri?
- WooCommerce Tabs [closed]
- Shortcode with PHP issue “Undefined index”
- Override a function defined in wp-includes/comment-template.php
- ::before on open/close function [closed]
- REQUIRED: get_bloginfo(‘template_url’) was found in the file search.php. Use get_template_directory_uri() instead
- How to check if a PHP string is different than meta field?
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- Displaying posts based on category
- Countdown to date function?
- Creating a mobile site by adding a new class to the body tag from functions.php
- calling a custom field value inside functions.php
- Custom meta box values are not getting saved for my custom post type
- Issue with fetching mysql data and displaying results via shortcode in webpage
- Noindex Posts From Certain Authors In WordPress
- Show all tags within a category?
- WordPress check if current taxonomy has child
- get post id from wp_insert_post for get_template_part
- This function is deprecated; use mysql_real_escape_string() instead
- get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
- Custom Taxonomy Select Menu: Setting default option value?
- How to add author’s posts link (HTML + PHP) inside a function to output it
- How can I alter this code to accept a slug as well as an ID?
- Enqueueing a code block from an options framework
- Conditional On custom field plugin metabox
- Adding a ‘style=’ bit to image_send_to_editor output
- Post Views Code Hacks
- Closing WP_LINK_PAGES DIV ID w/After Argmuent
- Exclude function from running on a certain page
- Auto create Nextgen Gallery on post creation [closed]
- Hide media for non logged in users
- How to set value selected using select2 jquery plugin
- Adding an “Upgrade Subscription” button to an Elementor page
- Jetengine Forms – Media upload path
- Using ACF Relationship field to set post type to draft or published status
- Custom function that re-writes page title breaks when the Yoast plugin is activated
- is_front_page is not working in my functions.php
- Is it possible to update the dataset using update_post_meta
- update_user_meta as multiple value but with same meta key
- Hide payment method based on user role AND minimum cart value
- How can i avoid duplicate same post in wp?
- Update $wpdb query with AJAX
- Custom meta box is not displaying value showing tag as empty
- How to bind each “the_content” elements to a custom variables
- Permalink changes after several minutes after saving post
- how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
- Trying to publish a little bit of Javascript on the homepage AND at the bottom
- Custom Bulk Actions handler not firing
- Get field in readable word
- All categories options or All categories not Populating
- WordPress load javascript file if something… (after the page is loaded)
- Add class for the_post_thumbnail_caption()
- How can disable wordpress emails notifications?
- Wrapping shortcode content in a span or link
- What is the best practice for restricting a section to logged in users?
- Permission functions within wordpress
- Adding ID to a Listing but not inside WP_Query while
- WordPress display name string manipulation
- 2 small questions: How to redirect to a created page & show that pages title in wp, bp
- ACF Date fileds to Age Convert [closed]
- How do I get Roboto Google Font to display normal font-style? [closed]
- which table updated after logout?
- Accessing WordPress Functions get_permalink() in Vanilla PHP?
- how to loop through blog posts in php
- Automatically change insurance quantity based on cart total [closed]
- How to pass value to add_filter wpcf7_form_tag from another function?
- hiddenQuestions.find is not a function