You can’t use an action or hook within a function in the way you are expecting. Actions and hooks are about delayed execution You are attaching code that will execute at a later point. After an action is added, your function will continue as normal.
Then when the user is actually being registered, your code will run. You will never get back to your original function though.
You might want to consider using multiple actions, and global variables. In the first action we can set the global:
add_action( 'user_register' .....
global $myvariable;
.
.
.
echo $user_id;
var_dump ($_POST);
$myvariable="a Value";
.
.
.
}
Then you can have another action that you fire somewhere else later. Here we can call on this global data:
add_action('wp_footer', function() {
global $myvariable;
echo $myvariable;
});
Related Posts:
- Hooking new functions to actions + passing parameters
- Modify custom field input data before creating a new post
- WordPress redirect redirecting too many times or not at all
- Hook into all password resets in WordPress and get password before hashing?
- WordPress HTML Helper
- Is there a hook that I can use when a fatal error occurs?
- what is correct way to hook when update post
- Enforcing password complexity
- Check php version before theme activation
- Change the footer text on the login page
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- How to remove a metabox from menu editor page?
- Can i check if user is doing any ajax request?
- Check if page parent has certain template
- How to Remove a Filter from the Admin List Table?
- Find variables available at a given hook
- Why do filters/actions require an argument count?
- Is $hook a global variable in WordPress
- Delete option value from array using update_option()
- Insert all post IDs in new database table
- How to access function from outside of a class within this class in WP plugin?
- action hook wp_head higher priority as all other plugins/hooks
- How to use return in my custom function instead of echo
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Handling Body class based on Template
- Adding Default Settings to Theme My Login plugin
- Remove an action hook within a Class
- How to pass arguments to add_action() or retrieve return value of called function?
- add_action shortcut?
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Why ajax doesn’t work on certain wordpress hooks?
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- Set meta field to publish date + 2 weeks
- WordPress Gravatar filter is removing my custom attributes
- Error in custom php function doesn’t exist
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Return a numerical function value in Customizer controls
- Adding widgets to my plugin page instead of WordPress dashboard
- Adding function to Genesis genesis_header [closed]
- how to make custom ajax handler?
- Error call_user_func_array() expects parameter 1 to be a valid callback when using image_size_names_choose
- jQuery code not working when included in functions.php
- Should `wp_login` be used since it’s deprecated?
- Override a function defined in wp-includes/comment-template.php
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Nested “do” and “add” Actions is possible?
- Run a code only on theme activation only during first activation
- Theme not calling Jquery properly
- Are there action hooks for comments?
- How to catch wordpress post ID when it’s published
- Why does the post_type_link hook everything twice?
- How to have different site identity logos on each page on Astra Theme [closed]
- How can I hook into the wp_mail function used by BackWPup?
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- Get user custom field value on function.php
- Adding function to child theme’s function.php
- Must filter functions receive all arguments passed to them?
- Creating customized php files in theme folder
- Dynamically Generate Functions and Hooks
- How do I add a function to parent theme
- Contain multiple page templates in one PHP custom template file in WordPress?
- Wp_Schedule_Event every few minutes doesn’t work
- remove_action from parent theme using child theme functions.php
- Adding custom field to product category and show it to shop/category shop page
- Custom meta box is not displaying value showing tag as empty
- Get original value in save_post action hooka
- Discount in the specific product title using keyword ( Woocoommerce )
- How do I get the value of a current user’s custom field?
- How do I remove an action hook inside a class that is called by another class?
- Getting page / post URL on publish and / or update
- remove_action() not working in page template – Genesis
- Unable to pass arguments to function used in add_action
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Why transition_post_type hook is called twice for the same post?
- Highlight posts currently being edited on multiple editor site?
- How to add custom checkout field in user details mail template
- Cannot modify header information – headers already sent
- Assign new post author IF another user in custom field on post transition
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- Why a class property becomes empty?
- transition_post_status hook, works – but not if the post is new
- Execute wp_after_insert_post after the permalink is customized
- Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook
- Disable RSS /feed/ endpoints on posts without disabling RSS overall
- How to set and use global variables? Or why not to use them at all
- How can I see all the actions attached to an “add_action” hook?
- How to deprecate a function used in a plugin?
- How to manually fix the WordPress gallery code using PHP in functions.php?
- How to make a image-size selected by default in Media upload – WP v3.5
- What is This esc_html_e() i wordpress php?
- Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
- How to Add Image to WordPress RSS-Feed with no Plug-in?
- Function to return true if current page has child pages
- How do I change/modify the_post_thumbnail(); html output?
- Mega Menu Walker
- start_lvl Ignored in Custom walker_nav_menu
- PHP code in page template vs functions
- Using register_activation_hook in classes
- Apply class to every paragraph that holds image?