I want to change the add event url to go

I want to change the add event url to go to ibsregister.com/add-event/

Instead of

ibsregister.com/members/baobab/my-events/edit-event/

I have tried adding

function replace_add_event() {
		remove_action( 'eab-events-my_events-set_up_navigation', array(Eab_Events_FrontPageEditing(), 'my_events_add_event') );

		function new_add_event () {
			global $bp;
			bp_core_new_subnav_item(array(
				'name' => __('Add Event', Eab_EventsHub::TEXT_DOMAIN),
				'slug' => 'add-event',
				'parent_url' => trailingslashit(trailingslashit($bp->displayed_user->domain)),
				'parent_slug' => '',
				'screen_function' => 'bind_bp_add_event_page',
			));
		}

		add_action( 'eab-events-my_events-set_up_navigation', array(Eab_Events_FrontPageEditing(), 'new_add_event'));	

	}

	add_action( 'eab-events-my_events-set_up_navigation', 'replace_add_event' );

To function.php but that doesn't work. I just get a blank screen

Thanks

  • aristath

    Hello there @Johanna, I hope you're well today!

    Instead of this:
    remove_action( 'eab-events-my_events-set_up_navigation', array(Eab_Events_FrontPageEditing(), 'my_events_add_event') );

    Try using this:
    remove_action( 'eab-events-my_events-set_up_navigation', array( 'Eab_Events_FrontPageEditing', 'my_events_add_event') );
    Then, add a priority higher than 10 to your final add_action call like this:
    add_action( 'eab-events-my_events-set_up_navigation', 'replace_add_event', 20 );
    This is because an action can only be removed after it has been added... since the default priority is 10, this is when it is added so you will have to use a higher priority to make sure you remove it after it has been added.

    Let me know if that works!

    Cheers,
    Ari.

  • Johanna

    This is now my code and it still isn't working

    function replace_add_event() {	
    
    		remove_action( 'eab-events-my_events-set_up_navigation', array( 'Eab_Events_FrontPageEditing', 'my_events_add_event') );
    
    		function new_add_event () {
    			global $bp;
    			bp_core_new_subnav_item(array(
    				'name' => __('Add Event', Eab_EventsHub::TEXT_DOMAIN),
    				'slug' => 'add-event',
    				'parent_url' => trailingslashit(trailingslashit($bp->displayed_user->domain)),
    				'parent_slug' => '',
    				'screen_function' => 'bind_bp_add_event_page',
    			));
    		}
    
    		add_action( 'eab-events-my_events-set_up_navigation', array('Eab_Events_FrontPageEditing', 'new_add_event'));	
    
    	}
    
    	add_action( 'eab-events-my_events-set_up_navigation', 'replace_add_event', 20 );

    The add event link is still going to members/baobab/my-events/edit-event/

    It goes into replace_add_event() OK but obviously the remove isn't working. Also it isn't going into new_add_event at all

  • Johanna

    Problem solved. This works. I just need the global $bp;

    function replace_add_event(){
    		global $bp;
    		bp_core_remove_subnav_item( 'my-events', 'edit-event' );
    		bp_core_new_subnav_item(array(
    			'name' => __('Add Event', Eab_EventsHub::TEXT_DOMAIN),
    			'slug' => 'add-event',
    			'parent_url' => '/',
    			'parent_slug' => 'my-events',
    			'screen_function' => array($this, 'bind_bp_add_event_page'),
    		));
    	}
    
    	add_action('eab-events-my_events-set_up_navigation', 'replace_add_event',99);