Can someone help me with the php code to perform below task? I've been struggling with this for a while now. Thanks!

1. If user enters a term in exposed filter of a view
2. Get term enter by user
3. Save term
4. Apply term to view when user clicks on any page view that has exposed filter i.e. perform automatic filtering using term entered by user