This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Avg downloads per customer | |
| function sc_edd_avg_downloads_per_customer( $atts ) { | |
| $amount = 0; | |
| $query = new WP_Query( array( 'post_type' => 'download' ) ); | |
| foreach( $query->posts as $post ) { | |
| $amount = $amount + edd_get_download_sales_stats( $post->ID ); | |
| } | |
| $amount = $amount / edd_count_total_customers(); | |
| return number_format( $amount, 2 ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // recent payments | |
| function sc_edd_recent_payments( $atts ) { | |
| $p_query = new EDD_Payments_Query( array( | |
| 'number' => 12, | |
| 'status' => 'publish' | |
| ) ); | |
| $payments = $p_query->get_payments(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // API Request | |
| $url = 'http://localhost/um-api/get.user/?id=1'; | |
| // Include your public key and token to the URL | |
| $url = add_query_arg('key', '75d9a913782eee3d990e4464ce26213e', $url ); | |
| $url = add_query_arg('token', 'bae6ee38cf02a50a0ac8259eed34ceb9', $url ); | |
| // Process your request | |
| $request = wp_remote_get( $url ); | |
| $response = json_decode( wp_remote_retrieve_body( $request ) , true ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('um_after_user_is_approved', 'wp_role_contributor_after_um', 99 ); | |
| function wp_role_contributor_after_um( $user_id ) { | |
| $wp_user_object = new WP_User( $user_id ); | |
| $wp_user_object->set_role( 'contributor' ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #bbpress-forums .bbp-forums-list li { | |
| font-size: 12px !important; | |
| margin: 0px 12px 0 0 !important; | |
| } | |
| #bbpress-forums .bbp-forums-list li a { | |
| padding: 1px 4px; | |
| font-size: 12px; | |
| background: #eee; | |
| color: #666; | |
| display: inline-block; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* This code will sync the UM role based on WP role using gravity registration */ | |
| add_action("gform_user_registered", "um_gravity_user_role_sync", 200, 4); | |
| function um_gravity_user_role_sync($user_id, $config, $entry, $user_pass) { | |
| $user = new WP_User( $user_id ); | |
| $wp_role = $user->roles[0]; | |
| // if WP role is subscriber, set UM role to member | |
| if ( $wp_role == 'subscriber' ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* This code will update the user registered with gravity | |
| form and allow you to give him a specific UM community role */ | |
| add_action("gform_user_registered", "um_gravity_user_role_sync", 88, 4); | |
| function um_gravity_user_role_sync($user_id, $config, $entry, $user_pass) { | |
| update_user_meta($user_id, 'role', 'member'); // member can be your UM role slug | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* This example syncs both UM / WP role during user approval */ | |
| add_action('um_after_user_is_approved', 'sync_um_and_wp_role', 99 ); | |
| function sync_um_and_wp_role( $user_id ) { | |
| // Get UM role | |
| $role = get_user_meta( $user_id, 'role', true ); | |
| // Set WordPress role for same user | |
| $wp_user_object = new WP_User( $user_id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| The following code will require @gmail.com as domain | |
| for user registrations. | |
| You can change @gmail.com to any provider you want. | |
| The code below requires a user email to be collected during registration | |
| */ | |
| add_action('um_before_new_user_register', 'require_google_email_for_signup'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('um_after_register_fields', 'add_a_hidden_field_to_register'); | |
| function add_a_hidden_field_to_register( $args ){ | |
| echo '<input type="hidden" name="field_id" id="field_id" value="HERE_GOES_THE_VALUE" />'; | |
| } |
NewerOlder