Adding an option to a shortcode

Regarding Edit #3 I would rewrite it like this: //* Shortcode for getting users function list_of_users( $atts ) { extract( shortcode_atts( array( ‘display’ => ‘all’, ‘user’ => ’30’ ), $atts )); $content=””; switch ( $display ) { case ‘all’: $content = display_all_users(); break; case ‘single’: $content = display_single_user( (int) $user ); break; default: break; } … Read more

Assign random (and unique) user meta upon registration

You can use the hook user_register to modify user data upon registration. You can use the function add_user_meta to add custom data to a user. Example: add_action(‘user_register’, ‘add_pin_number’, 10, 1); function add_pin_number($user_id) { add_user_meta( $user_id, ‘pin_number’, $random_number , true ); } You can look for php function out there to help you creating the random … Read more

Using xprofile_insert_field

Your code does work. It’s just that you are declaring $xfield_args after you have made the call xprofile_insert_field( $xfield_args ); it should look like this add_action(‘bp_init’, ‘field_xprofile_twitter’); function field_xprofile_twitter() { global $bp; $xfield_args = array ( field_group_id => 1, name => ‘Twitter’, can_delete => false, field_order => 1, is_required => false, type => ‘textbox’ ); … Read more

Update user meta without lose of old data

If I understand problem correctly, you want to store name of multiple files in user meta field. add_user_meta function has fourth argument $unique which is false by default that means for each call to add_user_meta a new key-value pair is added, even if key already exists. add_user_meta has less clarification then the add_post_meta that does … Read more

Save buddypress xprofile data to author meta

Use this action hook found in buddypress/bp-xprofile/classes/class-bp-xprofile-profiledata.php do_action_ref_array( ‘xprofile_data_after_save’, array( $this ) ); You’ll need to use the actual field_id for your xprofile description. This example assumes it is 25. You can get the field_idby going to wp-admin > Users > Profile Fields and clicking ‘Edit’ on that field. The field_id will appear in the … Read more

Order By Meta_key but convert custom date to Y-m-d first

I actually found a cool value for the orderby option in this case. meta_value_datetime It works the same as using strtotime and the date methods in PHP. So here is my final code that started working: $wp_query=new WP_Query(array ( ‘post_type’ => ‘sermon’, ‘meta_key’ => ‘sermon_date’, ‘orderby’ => ‘meta_value_datetime’, ‘order’ => ‘DESC’, ‘posts_per_page’ => -1 ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)