Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi there, i am trying to do the same.

    I used ACF to add custom meta urls in user post types, and i want to display these values dynamically in Elementor buttons via dynamic tags.

    I was able to add the php snippet into my functions.php file and to add the shortcode in the elementor button url, however when i try clicking the button in my frontend with a logged in account which also has the field + corresponding value `document_url’, i get redirected to: ‘about:blank#blocked’

    When i try to add the shortcode [custom_display_document_url] without a button, nothing happens and ‘[custom_display_document_url]’ appears in the frontend as it is.

    I think I didn’t use correct code in my functions.php template. This is the code i used:

    /**
     * Displays current user url.
     *
     * @return string
     */
    function custom_display_user_url_button() {
    	$html = '';
    
    	
    	// Check if user is logged in.
    	if ( is_user_logged_in() ) {
    		// Get current user object.
    		$user = wp_get_current_user();
    		// Check if user & user url is available and user url is not empty.
    		if ( $user && $user->document_url && ! empty( $user->document_url ) ) {
    			// Prepare html.
    			$html = sprintf( '<a href="%s" class="btn">%s</a>', esc_url( $user->document_url ), esc_html( 'Complete' ) );
    		}
    	}
    
    	// Return html.
    	return $html;
    }
    add_shortcode( 'custom_display_document_url', 'custom_display_document_url_button' );
    Thread Starter bsfundiz

    (@bsfundiz)

    Anybody??

Viewing 2 replies - 1 through 2 (of 2 total)