1

I used some X hook in function.php. I need to know which page trigger this action, need to get referrer URL and redirect to that page with success meassage.

function bp_plugin_hook_activity_posted_update( $content, $user_id, $activity_id, $event_id ) {

$userEmails = 'xxx@gmail.com';

if(!empty($userEmails))
    wp_mail( $userEmails, 'shared an event!', "content" , 'Content-Type: text/html' );

}

add_action( 'bp_activity_posted_update', 'bp_plugin_hook_activity_posted_update', 10, 3 );

Refer below AJAX resuest,

action:post_update
cookie:bp-members-scope%3Dall%26bp-activity-oldestpage%3D1
_wpnonce_post_update:df8c1689d4
content:http://localhost/sitename/event/atx-startup-crawl-at-austin-startup-week-2017/
event_id:1132
visibility:followers
object:
_bp_as_nonce:

2 Answers2

1

You can get it using wp_get_referer() and wp_get_original_referer() functions.

JDandChips
  • 9,780
  • 3
  • 30
  • 46
-1

Create js referrer variable with wp_localize_script, in data ajax pass this variable and process it in your function

Mykyta Dudariev
  • 462
  • 5
  • 17
  • would you explain bit briefly – Gnanasekaran Loganathan Aug 17 '17 at 14:36
  • @GNANA I do not see your code. Therefore answered abstractly – Mykyta Dudariev Aug 17 '17 at 14:43
  • This is core wp-admin-ajax action, refer below for AJAX request , action:post_update cookie:bp-members-scope%3Dall%26bp-activity-oldestpage%3D1 _wpnonce_post_update:df8c1689d4 content:http://localhost/sitename/event/atx-startup-crawl-at-austin-startup-week-2017/ event_id:1132 visibility:followers object: _bp_as_nonce: – Gnanasekaran Loganathan Aug 18 '17 at 05:56
  • I don't see what the benefit of involving `wp_localize_script` would be? If there was a good reason for this, then you forgot to include it in your 'abstract' answer. This isn't very helpful. – JDandChips Apr 29 '20 at 09:43