Hello,
I am looking to make it so that After a BuddyPress registration is confirmed (‘bp_after_registration_confirmed’)
WordPress automatically creates a new post (‘ wp_insert_post ‘) with contents based off user registration input.
Would it be best to insert this new function in register.php, or elsewhere?
Thanks
Hi Brian
Good to know that it is working. If I were you, I would have used the activation hook instead to be sure that the post is created when accounts are activated. Using ‘bp_core_activated_user’ this hook and code should be in bp-custom.php
All the best with your project.
Thank You
RaviHi Ravi,
Thanks for the tip. I tried this and it is working properly to add a new post on user activation.
Do you know of a way to get user data for the Title field?
I am trying like
$userid = bp_loggedin_user_id();
$bandname = xprofile_get_field_data( ‘Band Name’, $userid, $multi_format = ‘comma’ );
….
‘post_title’ => $bandnameBut it seems it is not parsing this information properly as post title output is ‘(no title)’.
I am trying this with BP-AutoLogin-On-Activation plug-in so the user is logged in upon activation https://buddydev.com/plugins/bp-autologin-on-activation/
Any tips?
Thank you!
Hi Brian,
Please try this way. Don’t use above code
function buddydev_create_post_on_activation( $user_id, $key, $user ) { //do something like this $field_id = "Your field ID"; $bandname = xprofile_get_field_data( $field_id, $user_id ); } add_action( 'bp_core_activated_user', 'buddydev_create_post_on_activation', 10, 3 );
Thank You
RaviChecked MySQL tables and the field for Band Name is just simply “1”.
Tried your code to echo out in profiles.php. Worked perfectly.
Tried the code in bp-custom.php and still outputs (no title).
Maybe since bp-custom.php loads before the page it is not seeing logged in user id?
edit: just saw your new reply. Will update in a minute
- This reply was modified 8 years, 3 months ago by
Brian.
- This reply was modified 8 years, 3 months ago by
You must be logged in to reply to this topic.