• Resolved chihi108

    (@chihi108)


    I tried to add a custom php code for adding tabs for the ultimate Member plugin, but it does not reflect in front end when added to the child theme of GP so it works only when added to the main theme of GP. Any thing which I may not be doing correctly? Obviously if the code is left in the main theme it will get overwritten when the main theme is updated. Any solution please?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Leo

    (@leohsiang)

    Hi there,

    That’s strange. The code should work in both the parent theme and child theme.

    Are you using a child theme from our site?
    https://docs.generatepress.com/article/using-child-theme/

    Any other functions in there?

    Thread Starter chihi108

    (@chihi108)

    I paste the function.php file from the child theme here but basically the line in the code starting from // Filter
    function um_add_custom_tabs( $tabs ) {

    downward does not reflect in the front end whereas it works OK with the Main theme,
    The full codes are as below. If there is a direct link to child theme then I can also try that

    <?php
    /**
     * GeneratePress child theme functions and definitions.
     *
     * Add your custom PHP in this file. 
     * Only edit this file if you have direct access to it on your server (to fix errors if they happen).
     */
    
    function generatepress_child_enqueue_scripts() {
    	if ( is_rtl() ) {
    		wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );
    /** Code for default Country Phone field Caldera Form **/
    add_filter( 'caldera_forms_phone_js_options', function( $options){
    	//Use ISO_3166-1_alpha-2 formatted country code
    	$options[ 'initialCountry' ] = 'GB';
    	return $options;
    });
    // Filter
    function um_add_custom_tabs( $tabs ) {
        $tabs['profile'] = array(
            'name' => 'Edit Profile',
            'icon' => 'um-faicon-pencil',
            'custom' => TRUE
        );
    
        return $tabs;
    }
    add_filter( 'um_profile_tabs', 'um_add_custom_tabs', 1000 );
    
    // Action
    
    function um_profile_content_profile_default( $args ) {
        wp_redirect( "/ultimate/user/?um_action=edit" );
    }
    add_action( 'um_profile_content_profile_default', 'um_profile_content_profile_default' );
    
    function custom_um_logout_add_tab( $tabs ) {
    
    	$tabs[ 'logout' ] = array(
    		'name'   => 'Logout',
    		'icon'   => 'um-faicon-sign-out',
    		'custom' => true
    	);
    
    	UM()->options()->options[ 'profile_tab_' . 'logout' ] = true;
    
    	return $tabs;
    }
    add_filter( 'um_profile_tabs', 'custom_um_logout_add_tab', 1000 );
    function custom_um_logout_action() {
    	if ( isset( $_GET['profiletab'] ) && 'logout' == $_GET['profiletab'] ) {
    		// Logout user
    		wp_logout();
    
    		// redirect to home page.
    		wp_redirect( home_url() );
    		exit;
    	}
    
    	if ( isset( $_GET['profiletab'] ) && 'account' == $_GET['profiletab'] && function_exists( 'um_get_core_page' ) ) {
    		$account_page = um_get_core_page( 'account' );
    		if ( $account_page ) {
    			// redirect to home page.
    			wp_redirect( $account_page );
    			exit;
    		}
    	}
    }
    add_action( 'template_redirect', 'custom_um_logout_action' );
    
    /* add new tab called "mytab" */
    
    add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 );
    function my_custom_tab_in_um( $tabs ) {
    	$tabs[800]['mytab']['icon'] = 'um-faicon-pencil';
    	$tabs[800]['mytab']['title'] = 'My Profile';
    	$tabs[800]['mytab']['custom'] = true;
    	return $tabs;
    }
    	
    /* make our new tab hookable */
    
    add_action('um_account_tab__mytab', 'um_account_tab__mytab');
    function um_account_tab__mytab( $info ) {
    	global $ultimatemember;
    	extract( $info );
    
    	$output = $ultimatemember->account->get_tab_output('mytab');
    	if ( $output ) { echo $output; }
    }
    
    /* Finally we add some content in the tab */
    
    add_filter('um_account_content_hook_mytab', 'um_account_content_hook_mytab');
    function um_account_content_hook_mytab( $output ){
    	ob_start();
    	?>
    		
    	<div class="um-field">
    		
    	Go to my Profile Page 	<a href="https://www.gbscuk.co.uk/user/" class="um-button button primary">Your Profile Page</a>
    		
    	</div>		
    		
    	<?php
    		
    	$output .= ob_get_contents();
    	ob_end_clean();
    	return $output;
    }
    Thread Starter chihi108

    (@chihi108)

    working now
    thanks

    Thread Starter chihi108

    (@chihi108)

    resolved

    Leo

    (@leohsiang)

    Glad to hear!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘code in function php child theme not reflecting’ is closed to new replies.