Title: Add custom attribute to shortcode
Last modified: April 23, 2018

---

# Add custom attribute to shortcode

 *  Resolved [Alex](https://wordpress.org/support/users/alexius94/)
 * (@alexius94)
 * [8 years ago](https://wordpress.org/support/topic/add-custom-attribute-to-shortcode/)
 * Hi,
 * Is there a way for me to add custom attributes to the shortcode like I need to
   know from which page the user register in from my site, so something like `[nextend_social_login
   from_page="homepage"]`
 * Could you give me some pointers on how to modify the plugin? I’ve managed to 
   pass the atts to the shortcode but I’m not sure how to access retrieve them from
   the NextendSocialUser::register function

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Ramona](https://wordpress.org/support/users/nextend_ramona/)
 * (@nextend_ramona)
 * [8 years ago](https://wordpress.org/support/topic/add-custom-attribute-to-shortcode/#post-10209508)
 * Hi [@alexius94](https://wordpress.org/support/users/alexius94/)
 * You can use the trackerdata attribute in your shortcode for this. E.g.: [nextend_social_login
   trackerdata=”homepage”]
 * and you can use a code like this to save it down:
 *     ```
       add_action('nsl_register_new_user', function ($user_id) {
           if (NextendSocialLogin::getTrackerData() == "homepage") {
               $user = new WP_User($user_id);
               add_user_meta($user->ID, 'registered_from', "homepage");
           }
       });
       ```
   
 * then you can use the get_user_meta() [https://codex.wordpress.org/Function_Reference/get_user_meta](https://codex.wordpress.org/Function_Reference/get_user_meta)
   
   to display this information anywhere.
 * You could make this a bit more dynamic using cookies. E.g. by setting up a cookie
   that stores the URL of the current page and saving that down at the add_user_meta()
   function.
 *  Thread Starter [Alex](https://wordpress.org/support/users/alexius94/)
 * (@alexius94)
 * [8 years ago](https://wordpress.org/support/topic/add-custom-attribute-to-shortcode/#post-10210447)
 * Nice that great! Thanks a bunch.
 *  Thread Starter [Alex](https://wordpress.org/support/users/alexius94/)
 * (@alexius94)
 * [8 years ago](https://wordpress.org/support/topic/add-custom-attribute-to-shortcode/#post-10212362)
 * Hi, another question, where would the best place to place the code? In functions.
   php or somewhere in the plugin folder?
 *  Plugin Support [Gabor](https://wordpress.org/support/users/nextendweb_gabor/)
 * (@nextendweb_gabor)
 * [8 years ago](https://wordpress.org/support/topic/add-custom-attribute-to-shortcode/#post-10212399)
 * Hi [@alexius94](https://wordpress.org/support/users/alexius94/)!
 * You should probably write a new plugin for this. This could help getting started,
   if you haven’t done that before:
    [https://corpocrat.com/2009/12/27/tutorial-how-to-write-a-wordpress-plugin/](https://corpocrat.com/2009/12/27/tutorial-how-to-write-a-wordpress-plugin/)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Add custom attribute to shortcode’ is closed to new replies.

 * ![](https://ps.w.org/nextend-facebook-connect/assets/icon.svg?rev=3336394)
 * [Nextend Social Login and Register](https://wordpress.org/plugins/nextend-facebook-connect/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nextend-facebook-connect/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nextend-facebook-connect/)
 * [Active Topics](https://wordpress.org/support/plugin/nextend-facebook-connect/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nextend-facebook-connect/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nextend-facebook-connect/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Gabor](https://wordpress.org/support/users/nextendweb_gabor/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/add-custom-attribute-to-shortcode/#post-10212399)
 * Status: resolved